我正在与发布版本的Xcode 7.0建设。没有故事板,只是笔尖文件。尝试加载视图控制器的视图,当它正在释放... UIAlertController
我有一个由应用程序委托创建的UINavigationController
并使用视图控制器初始化它。
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIViewController *viewController = [[TGMainViewController alloc] initWithNibName:nil bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationController.navigationBar.hidden = YES;
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
使用导航到一个新视图后:
TGRoutePreparationViewController *viewController = [[TGRoutePreparationViewController alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:viewController animated:YES];
然后回去用:
[self.navigationController popViewControllerAnimated:YES];
我收到以下错误:
Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<UIAlertController: 0x7b29a600>)
虽然我在t中使用UIAlertController
他的应用程序,没有人在使用或实例化之前收到此错误。这只在iOS 9.0下运行时才会发生。在iOS 8.4下运行不会产生错误。在所有情况下,该应用似乎都能正常运行,并且导航似乎正在工作。
我怀疑错误是误导,但我该如何解决这个问题?
每@Nick,这里是正在使用的dealloc方法:
- (void)deregisterNotificationHandlers {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)dealloc {
[self deregisterNotificationHandlers];
}
我强烈怀疑哟你在某个地方使用UIAlertController,并没有意识到这一点,也不打算这么做。在提供UIAlertControllers的地方设置断点并查看会发生什么 – Paulw11
我在+ [UIAlertController alertControllerWithTitle:message:preferredStyle:]上设置了断点,但没有设置断点。我后来创建了一个警报,断点确实起作用。 – picciano
你是否在任何地方重写'dealloc'?你能发布更多的代码吗? – Nick