IOS 6: What has changed to break the View Controller hierarchy?

In AppDelegate, the following:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; customViewController = [[CustomViewController alloc] initWithNibName:@"CustomViewController" bundle:nil]; self.navigationController = [[UINavigationController alloc] initWithRootViewController:customViewController]; [self.navigationController setNavigationBarHidden:YES]; self.window.rootViewController = self.navigationController; [self.window makeKeyAndVisible]; 

In the actual XIB, the view is associated with β€œFile Owner,” and this is my only association.

XIB Hierarchy:

 Navigation Controller - View Controller - Root View Controller -View (Associated with File Owner) 

Sorry if I do not understand this, it worked perfectly in a previously launched application, but I understand that this does not mean that it was correct.

Edit: Sorry, here is the error I get:

* Application termination due to the uncaught exception "UIViewControllerHierarchyInconsistency", reason: "View can be associated with only one view controller! View <UIView: 0xa192d00; frame = (0 20; 320 460); autoresize = W + H; layer = <CALayer: 0xa192d60 β†’ associated with <UIViewController: 0xa195c70>. Clear this association before associating this view with <CustomViewController: 0xa1802a0>. '

+4
source share
1 answer

Make sure that the interface of your views does not have an additional view controller in its hierarchy. See screenshots below.

Before:
Before

After:
After

+18
source

Source: https://habr.com/ru/post/1436425/


All Articles