Search code examples
iosobjective-cstoryboardsegue

Crash when trying to open a viewcontroller via storyboard reference


I've got a segue that opens a viewcontroller via a storyboard reference in the viewDidLoad of the parent controller. Everything worked in the earlier versions of iOS and Xcode, however it seems to give me a crash now with the message

[Assert] Assuming bar button item's view exists.

I'm not sure what to do - I've tracked the crash down to the line which references the segue that opens the referenced viewcontroller.

I've set the anchor as the bar button item.

[self performSegueWithIdentifier:@"menuPopSegue" sender:nil];

Solution

  • I moved my code into the viewDidAppear method instead of the viewDidLoad (where it originally was). It now works and presents the viewController in a popOver - I assume the problem was because in the viewDidLoad items were initialised but not actually presented yet on screen and the new UIPopoverPresentationController class requires the anchor and its properties to be fully loaded.