irie
irie

Reputation: 189

Detect popover dismiss in iOS8

in my iPad-app I connected a UIButton to another UIViewcontroller by just dragging in Storyboard and chose popover as segue. Everything is working fine, but the user can dismiss the popover by touching just somewhere besides the popover right.

How can I detect that the popover has dismissed in iOS8? In iOS7 I could just use the UIPopoverDelegate -popoverDidDidmiss...

But this is not working anymore!? I googled a lot but could not find any solution.

Upvotes: 0

Views: 433

Answers (4)

JapCon
JapCon

Reputation: 448

in iOS8, it is using the UIViewController's UIPopoverPresentationController to present the popover. (Optionally you still can use back the old UIPopoverController to build the popover manually.

If you are using storyboard on iOS8, you can set the UIViewController's popoverPresentationController delegate to handle the followings:

  • popoverPresentationControllerShouldDismissPopover:
  • popoverPresentationControllerDidDismissPopover:

Upvotes: 0

Croises
Croises

Reputation: 18671

You put your

-(void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController

in the UIViewController where the start UIButton is ? (not in another popover UIViewcontroller ?) That work well for me with iOS 8.1...

You have to delegate to the initial UIViewController for that.

Upvotes: 1

Adis
Adis

Reputation: 4552

You should probably use UIPopoverControllerDelegate and the method

popoverControllerDidDismissPopover:

to accomplish what you need.

Upvotes: 0

konrad
konrad

Reputation: 1724

I assume you set the delegate properly, but do you retain the popover, i.e. assign it to a strong property? In ios7 if you didn't retain the popover you would get exception: '[UIPopoverController dealloc] reached while popover is still visible.' In ios8 this is not longer the case, so you get the working popover and you can dismiss it, but the delegate methods are not called anymore.

(Frankly speaking, I'm not sure why this is so. I'd suppose that at least "should dismiss popover" should be called anyway).

Upvotes: 0

Related Questions