Question

I want to choose storyboard segue style to be popover but dont see it in segue style field.

Story board Action segue presents only Push, modal and custom.

Have UIBarButtonItem for which i want to choose popover storyboard segue.

Any suggestions please.

Was it helpful?

Solution

Go to simulated metrics and you should find it. Here is an image of where it is. Note that popover is available only in iPad not in iphone through simulator.

enter image description here

Edit:

Here is sample code for using a button and action method to create a popover:

You will need to declare a popoverController property:

  @property (nonatomic, strong) UIPopoverController* buttonPopoverController;

Then your button action can look something like this:

  - (void) buttonTapped:(UIButton*) sender
  {
  ContentViewController* contentVC = [[ContentViewController alloc] init];
  self.buttonPopoverController = [[UIPopoverController alloc]
                                 initWithContentViewController:contentVC];
  self.buttonPopoverController.delegate = self;  
       //only required if using delegate methods

 [self.buttonPopoverController presentPopoverFromRect:sender.frame
                       inView:self.view
     permittedArrowDirections:UIPopoverArrowDirectionAny
                     animated:YES];
  }

The ContentViewController is whichever view controller you are intending to segue to. If it is configured using a storyboard scene, you may want to do something like this when you create it:

  UIStoryboard *storyboard = self.storyboard;
  ContentViewController* contentVC = 
 [storyboard instantiateViewControllerWithIdentifier:@"ContentViewController"];

You can set the storyboard identifier using the Identity Inspector when you have the relevant view controller selected in the storyboard.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top