iOS 8' NSInternalInconsistencyException',原因:'尝试用未知的演示者解雇UIAlertController。'

时间:2014-07-29 18:13:18

标签: objective-c xcode ios8

iOS8已弃用UIAlertview,需要使用UIAlertController

我正在尝试使用Xcode 5.1进行编译并在iOS 8 beta 4设备上运行,因此我无法直接实例化UIAlertController。我发现在代码库中的大多数地方使用UIAlertView没有问题,除了几个类,即故事板的Appdelegate和initialViewController。我试图创建一个自定义视图控制器来处理UIAlertView以查看它是否已修复但是静止不动。任何线索?提前谢谢。

1 个答案:

答案 0 :(得分:2)

尝试使用以下类型的代码显示警报视图之前添加延迟:

 dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 1.0 * NSEC_PER_SEC); 
            dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
                UIAlertView *crashAlert = [[UIAlertView alloc] initWithTitle:@"Alert"
                                                                     message:@"XYZ"
                                                                    delegate:self
                                                           cancelButtonTitle:@"No"
                                                           otherButtonTitles:@"Yes",@"Always", nil];
                [crashAlert show];

            });

这对我有用。