Crashlytics 在我的应用中向我发送此错误:
Fatal Exception: NSInternalInconsistencyExceptionTrying to dismiss UIAlertController <UIAlertController: 0x14de40020> with unknown presenter.UIKit - [ UIAlertController _dismissAnimated:triggeringAction:triggeredByPopoverDimmingView: ] + 584
仅在 iOS 8 中会出现此问题 , 但是当我尝试重现此错误时 , 我的 alertViews 在 iOS 8 中可以正常工作 , 并且不会发生任何不良情况 . 为什么会发生此问题?
我已经阅读到 iOS 8 中不推荐使用 UIAlertView, 现在 , 我们必须使用 UIAlertController, 但是当我尝试使用 UIAlertController 时 , 无法关闭警报 , 并且功能也不相同 .
请帮我 .
谢谢您的提前 .
编辑:
我要更改的代码是这样的:
UIAlertView * alerta = [ [ UIAlertView alloc ] initWithTitle: AMLocalizedString ( @"alertUpdate", @"" ) message:@"" delegate:self cancelButtonTitle:nil otherButtonTitles:nil ] ;UIActivityIndicatorView *spinner = [ [ UIActivityIndicatorView alloc ] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray ] ;spinner.center = CGPointMake ( 139.5, 75.5 ) ; // .5 so it doesn't blur [ alerta addSubview:spinner ] ; [ spinner startAnimating ] ; [ alerta show ] ;UIStoryboard *storyBoard = [ UIStoryboard storyboardWithName:dis bundle:nil ] ;MainVC *main = [ storyBoard instantiateViewControllerWithIdentifier:@"MainVC" ] ;UINavigationController *navControl = [ [ UINavigationController alloc ] initWithRootViewController: main ] ; [ self presentModalViewController: navControl animated: YES ] ; [ alerta dismissWithClickedButtonIndex:0 animated:YES ] ;
最佳答案
取代这个
[ self presentModalViewController: navControl animated: YES ] ; [ alerta dismissWithClickedButtonIndex:0 animated:YES ] ;
有了这个
[ alerta dismissWithClickedButtonIndex:0 animated:YES ] ; [ [ NSOperationQueue mainQueue ] addOperationWithBlock:^{ [ self presentModalViewController: navControl animated: YES ] ;} ] ;
这以异步方式提供了一个新的控制器 , 以确保警报视图被关闭