我正在使用Xcode 7.0的发行版进行构建.没有故事板,只有nib文件.
我有一个应用程序委托创建的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>)
虽然我在应用程序中使用了UIAlertController
个,但在收到此错误之前,没有使用或实例化任何一个.只有在iOS 9下才能运行.在iOS 8.4下运行不会产生错误.在所有情况下,应用程序似乎都能正常运行,导航系统似乎也能正常工作.
我怀疑这个错误有误导性,但我该如何解决这个问题呢?
Per@Nick,这里是正在使用的dealloc方法:
- (void)deregisterNotificationHandlers {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)dealloc {
[self deregisterNotificationHandlers];
}