objective-c - iOS 8 'NSInternalInconsistencyException',原因 : 'Trying to dismiss UIAlertController with unknown presenter.'

标签 objective-c xcode ios8

iOS8 已经弃用了UIAlertview,需要使用UIAlertController

我正在尝试使用 Xcode 5.1 进行编译并在 iOS 8 beta 4 设备上运行它,因此我无法直接实例化 UIAlertController。我看到在代码库的大多数地方使用 UIAlertView 没有问题,除了几个类,即 Storyboard的 Appdelegate 和 initialViewController。我试图创建一个自定义 View Controller 来处理 UIAlertView 以查看它是否已修复但在静脉中。有什么线索吗?提前致谢。

最佳答案

尝试使用以下代码在显示警报 View 之前添加延迟:

 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];

            });

这对我有用。

关于objective-c - iOS 8 'NSInternalInconsistencyException',原因 : 'Trying to dismiss UIAlertController with unknown presenter.' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25022201/

相关文章:

ios - 从iBook获取文件/文档目录到我的应用程序

objective-c - Objc : Class X is implemented in both Y and Z . 将使用两者之一。哪个是未定义的

ios - WatchKit NSUserDefaults 为空

iphone - 从头开始申请iphone开发者证书?

iOS 8 UIActionSheet 忽略 View Controller supportedInterfaceOrientations 和 shouldAutorotate

ios - 在 Swift 中为 Controller 属性赋值

ios - UIImagePickerController 与 AVCaptureSession 视频预览冲突

iphone - 如何从 JSON 中获取 bool 值?

objective-c - 在 NSView 上使用 NSPoint 鼠标跟踪

swift - 将 GroupActivities 与 Objective-C 类一起使用?