我的应用程序中的几个ViewControllers必须显示相同的UIAlertView,并以相同的方式执行- manner视图:clickedButtonAtIndex:方法。我不想在几个文件中编写相同的代码,所以我需要有一种全局UIAlertView,其中包含一个可用于所有ViewControllers的alertView: clickedButtonAtIndex:方法。我已经创建了一个方法来调用我的AppDelegate.m文件中的UIAlertView,并在相同的位置覆盖了alertView:clickedButtonAtIndex:,但不幸的是,alertView:clickedButtonAtIndex:没有从不同的文件中调用。你有什么想法吗?耽误您时间,实在对不起
发布于 2012-01-05 23:05:40
为什么不将UIViewController子类化以拥有UIAlertView所需的所有功能,然后让AppDelegate在导航堆栈上的当前子类化UIViewController上调用该方法。希望这能有所帮助!
发布于 2012-01-05 23:05:54
当您在其他视图控制器中创建UIAlertView时,请确保将委托设置为您的AppDelegate (或声明clickedButtonAtIndex:方法的任何位置)。
https://stackoverflow.com/questions/8744614
复制相似问题