【发布时间】:2015-04-15 11:38:56
【问题描述】:
我的应用程序崩溃了,一定是因为 UIAlertController。
此问题仅在 UIAlertController 可用的 iOS 8.x 上发生。奇怪的事实是我的应用程序既不使用 UIAlertViewController 也不使用 UIAlertView。
报告告诉我:
Trying to dismiss UIAlertController <UIAlertController: 0x172c5d80> with unknown presenter.
这怎么会发生?
我想过
- 由于摇晃手势而显示的 System AlertView 撤消
- 当提示或通用对话框仍在屏幕上时,WebView 被释放
- 低电量警报
但没有一个案例让我陷入崩溃。
崩溃日志对我的建议是,操作系统显示了一个 AlertView,它将附加到我的应用程序窗口,并且在某些情况下会丢失显示 UIAlertViewController 的父视图控制器。
任何想法如何找到问题?
这里是堆栈跟踪
_________________________________
0 CoreFoundation 0x2bc0c45f __exceptionPreprocess + 127
1 libobjc.A.dylib 0x39c79c8b objc_exception_throw + 36
2 CoreFoundation 0x2bc0c3a5 +[NSException raise:format:] + 110
3 UIKit 0x2f4ad13d -[UIAlertController _dismissAnimated:triggeringAction:triggeredByPopoverDimmingView:] + 414
4 UIKit 0x2f4acf97 -[UIAlertController _dismissAnimated:triggeringAction:] + 28
5 UIKit 0x2f590a0b -[_UIAlertControllerActionView touchesEnded:withEvent:] + 160
6 UIKit 0x2f159567 -[UIWindow _sendTouchesForEvent:] + 520
7 UIKit 0x2f152e31 -[UIWindow sendEvent:] + 542
8 UIKit 0x2f129759 -[UIApplication sendEvent:] + 194
9 UIKit 0x2f39d2f9 _UIApplicationHandleEventFromQueueEvent + 14166
10 UIKit 0x2f1281a9 _UIApplicationHandleEventQueue + 1350
11 CoreFoundation 0x2bbd2fbf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
12 CoreFoundation 0x2bbd23cf __CFRunLoopDoSources0 + 216
13 CoreFoundation 0x2bbd0a35 __CFRunLoopRun + 770
14 CoreFoundation 0x2bb1e3b1 CFRunLoopRunSpecific + 474
15 CoreFoundation 0x2bb1e1c3 CFRunLoopRunInMode + 104
16 GraphicsServices 0x3308d201 GSEventRunModal + 134
17 UIKit 0x2f18843d UIApplicationMain + 1438
18 MyApp 0x00028a07 main (main.mm:16)
编辑
holes 询问我的窗口初始化。这是我的 AppDelegate 的代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[MyAppCustomWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
_mainViewController = [[MyAppContainerViewController alloc] initWithNibName:nil bundle:nil];
_mainStatusBarVC = [[MyAppStatusBarVC alloc] initWithRootVC:_mainViewController];
[self.window setRootViewController:_mainStatusBarVC];
[self.window makeKeyAndVisible];
return YES;
}
【问题讨论】:
-
您是如何为您的应用初始化
UIWindow实例的? -
我在我的 AppDelegate 应用程序中初始化了 MyCustomWindow:didFinishLaunchingWithOptions: 然后我设置了 rootViewController 并使用 self.window makeKeyAndVisible 使其成为键和可见。我将用一些关于它的代码来编辑问题。
-
添加了有关 MyCustomWindow 初始化的代码。我有兴趣重现该问题,以确保任何类型的代码修复都可以肯定地解决该问题。我不知道为什么 UIAlertViewController 会显示在我的应用程序堆栈跟踪中。
-
从你的介绍中我看不出来。一定是有其他原因造成的。
-
完全正确...我错过了显示此系统警报的内容。必须是一个以某种方式干扰我的应用程序的系统进程,但我无法弄清楚。
标签: ios objective-c cocoa-touch uialertview stack-trace