0

I give up and need some help.

I am trying to implement a simple picker popover in xcode4 using the story board

I have created a storyboard and added a view which is a picker. I have linked a button to the view, and the view with the picker is displayed. The picker popover appears and I can select the value I want. When I dismiss the popover, I get no event. previously the method "popoverControllerDidDismissPopover" was called in the calling view. From here I could perform any post popover operations and retrieve any specific resultsI had calculated on the basis of the picker selection. This was all working previously.

What is the equivalent of the "popoverControllerDidDismissPopover" when using storyboards

Thanks

2 Answers2

4

Have your view controller that "owns" the popover/segue implement the UIPopoverControllerDelegate protocol, with the popoverControllerDidDismissPopover method. Also, make sure your segue is assigned an identifier in Interface Builder. Then, implement the prepareForSegue method:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender  
{
  if ([segue.identifier isEqualToString:@"MyPopoverSegueIdentifier"]) {
    UIStoryboardPopoverSegue* popSegue = (UIStoryboardPopoverSegue*)segue;
    popSegue.popoverController.delegate = self;
    // also set any properties of the popover view controller itself:
    // popSegue.destinationViewController.someProperty = xyz
  }
}

Now you'll receive the popoverControllerDidDismissPopover messages as expected.

Mike Mertsock
  • 11,825
  • 7
  • 42
  • 75
  • 1
    Thanks for the response. I found a way in the end based very much on the way you described above for set up. And then used a delegate action from the popover when returning data and tidying up the popover at the same time. However, I never did get the popoverControllerDidDismissPopover event – 1961DarthVader Nov 13 '11 at 13:45
0

I don't know the xcode equivalent since I am a MonoTouch user, but I do know that the DidDismiss event is not fired when you programatically dismiss the popover (see the Apple documentation). It is only called when the popover is dismissed by the user selecting another element.

To resolve this issue in MonoTouch, we had to subclass the UIPopoverController, add our own event, override the Dismiss method, and fire the new event in the override method. This way, it is called whether the popover is dismissed programatically or by the user.

competent_tech
  • 44,465
  • 11
  • 90
  • 113
  • Thanks. I am trying to use only the standard tools, so so far I don't have any programming to dismiss the popover, it is all done via the storyboard background stuff, which is great. I am afraid that I might have to get down and dirty which seems a little OTT for what was a nice simple event. – 1961DarthVader Nov 06 '11 at 20:15
  • I haven't used the storyboard functionality, but from your observation/explanation, I am guessing that it is dismissing the popover programatically and thus not firing the event. – competent_tech Nov 06 '11 at 20:19