I have a UIToolbar that sits at the bottom of the view. When the user is on an iPad, I want to add the toolbar to the right side of the navigation controller, because there will be room.
I added this code:
- (void)viewDidLoad{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
UIBarButtonItem *toolBarItem = [[UIBarButtonItem alloc]initWithCustomView:toolBar];
self.navigationItem.rightBarButtonItem = toolBarItem;
}
[super viewDidLoad];
}
But the application crashes with the error:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. UINavigationBar's implementation of -layoutSubviews needs to call super.'
I don't know why this is a problem, because I have seen this method used before. By the way, the toolbar items are added in interface builder rather than using an NSArray of buttons, could that make a difference?
Thanks!