I am building with the release version of Xcode 7.0. No storyboards, just nib files.
I have a single UINavigationController
created by the app delegate and initialize it with a view controller.
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];
After navigating to a new view using:
TGRoutePreparationViewController *viewController = [[TGRoutePreparationViewController alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:viewController animated:YES];
Then going back using:
[self.navigationController popViewControllerAnimated:YES];
I receive the following error:
Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<UIAlertController: 0x7b29a600>)
While I do use UIAlertController
s in the app, none are used or instantiated before receiving this error. This only happens when running under iOS 9.0. Running under iOS 8.4 produces no error. In all cases, the app appears to function normally and the navigation appears to be working.
I suspect the error is misleading, but how can I fix this?
Per @Nick, here is the dealloc method being used:
- (void)deregisterNotificationHandlers {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)dealloc {
[self deregisterNotificationHandlers];
}
dealloc
anywhere? can you post more code? – Roustabout-deregisterNotificationHandlers
does is just call+[NSNotificationCenter removeObserver:]
, perhaps you can do that directly in-dealloc
and cut a superfluous method... – LeucotomyUIAlertViewController
to a property of the view controller? If so, in the alert's action handlers, do you happen to have any strong references which should really be weak? – ZimmerUIAlertControllers
in my application. However, my push was being initiated by resuming user activity viaapplication:continueUserActivity:restorationHandler:
in my AppDelegate. I had not overridenapplication:willContinueUserActivityWithType:
; according to this post, this can lead toUIAlertControllers
being shown, and hence the error message. Overriding theapplication:willContinueUserActivityWithType:
function solves the problem for me. – Kerek