Popover Segue Crashes when called programmatically

I am using XCode 4.2 storyboards. Initially I had a Popover Segue bound to a UIButton on a UIViewController embedded in a navigation controller and it was fine.

Now I need to add conditional behavior before executing the segue, so I did the following:

  • Removed segue
  • Created a new session from UIViewController
  • Created an IBAction using a button
  • Called [self performSegueWithIdentifier:@"mySegue" sender:self]

    in IBAction

The app goes through prepareForSegue but then issues SIGABRT and registers the following

 \*** Assertion failure in -[UIStoryboardPopoverSegue perform], /SourceCache/UIKit_Sim/UIKit-1912.3/UIStoryboardPopoverSegue.m:27


Any ideas? I have other examples of this working fine with push segues. Is this a case of misbehavior that I keep hearing?


source to share

1 answer

Maybe it's a little late:

The anchor defines the starting point of the popover you want to show and is not associated with an action. It must be installed.

So, if you want to call the popper segue programmatically, you need to do it in two steps:

1. Connect Segue to ViewController . You just drag and drop from the ViewController, which should segue on the target ViewController and select the Popover.

Connect Segue to ViewController

2. Determine the identifier . This is required to invoke the segue execution from your code.

3. Connect the anchor . You are dragging the anchor to the object you want the popover to start from. In the image below, this is BarButtonItem. Note: this is not done automatically! (So ​​you can additionally do some BarButtonItem related actions)

Connect the anchor

4. Call segue from your code

    [self performSegueWithIdentifier:@"yourIdentifier" sender:sender];




All Articles