我收到了与UIAlertController相关的崩溃报告,无法重现崩溃。
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Trying to dismiss UIAlertController <UIAlertController: 0x7a740910> with unknown presenter.'
Application Specific Backtrace 1:
0 CoreFoundation 0x034dfdda ___exceptionPreprocess + 154
1 libobjc.A.dylib 0x03169a97 _objc_exception_throw + 44
2 CoreFoundation 0x034dfd1d +[NSException raise:format:] + 141
3 UIKit 0x02268999 -[UIAlertController _dismissAnimated:triggeringAction:triggeredByPopoverDimmingView:] + 444
4 UIKit 0x022687d8 -[UIAlertController _dismissAnimated:triggeringAction:] + 56
5 UIKit 0x022683c4 -[UIAlertController _actionViewTapped:] + 68
6 libobjc.A.dylib 0x0317f771 -[NSObject performSelector:withObject:] + 70
7 UIKit 0x0244b06c -[_UIAlertControllerActionView _triggerSelect] + 60
8 UIKit 0x0244af27 -[_UIAlertControllerActionView touchesEnded:withEvent:] + 187
9 UIKit 0x023eb257 __UIGestureRecognizerUpdate + 13225
10 UIKit 0x0200471b -[UIWindow _sendGesturesForEvent:] + 1356
11 UIKit 0x0200557f -[UIWindow sendEvent:] + 769
12 UIKit 0x01fcaaa9 -[UIApplication sendEvent:] + 242
13 UIKit 0x01fda8de __UIApplicationHandleEventFromQueueEvent + 20690
14 UIKit 0x01faf079 __UIApplicationHandleEventQueue + 2206
15 CoreFoundation 0x034037bf ___CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
16 CoreFoundation 0x033f92cd ___CFRunLoopDoSources0 + 253
17 CoreFoundation 0x033f8828 ___CFRunLoopRun + 952
18 CoreFoundation 0x033f81ab _CFRunLoopRunSpecific + 443
19 CoreFoundation 0x033f7fdb _CFRunLoopRunInMode + 123
20 GraphicsServices 0x0564c24f _GSEventRunModal + 192
21 GraphicsServices 0x0564c08c _GSEventRun + 104
22 UIKit 0x01fb2e16 _UIApplicationMain + 1526
23 FantasyCricket 0x001435ad _main + 141
24 libdyld.dylib 0x04055ac9 _start + 1
我正在使用适用于iOS 8及更高版本的AlertController。
编辑:
显示提醒的示例代码:
if (NSClassFromString(@"UIAlertController"))
{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title
message:msg
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:nil];
[alert addAction:defaultAction];
//other UIAlertAction here......
[self presentViewController:alert animated:YES completion:nil];
}
else
{
[[[UIAlertView alloc]initWithTitle:title
message:msg
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil] show];
}
在appDelegate中也使用(通过获取当前控制器并在该控制器上显示警报),这是否会导致问题..?