Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 6: What changed that made this View Controller Hierarchy break?

The following is in my AppDelegate:

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 the "File's Owner" and that is my only association there..

XIB Hierarchy:

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

Sorry if I don't understand this, it was working fine on a previously launched app but I understand that does not mean it was correct.

Edit: Sorry here is the error I am getting:

* Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'A view can only be associated with at most one view controller at a time! View < UIView: 0xa192d00; frame = (0 20; 320 460); autoresize = W+H; layer = < CALayer: 0xa192d60>> is associated with < UIViewController: 0xa195c70>. Clear this association before associating this view with < CustomViewController: 0xa1802a0>.'

like image 496
John Sloan Avatar asked Dec 01 '22 21:12

John Sloan


1 Answers

Make sure your views' interface does not have an extra view controller in its hierarchy. See the screenshots below

Before:
Before

After:
After

like image 104
Jonathan Avatar answered Dec 11 '22 10:12

Jonathan