0

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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
irie
  • 189
  • 1
  • 9

4 Answers4

1

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.

Croises
  • 18,570
  • 4
  • 30
  • 47
0

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).

konrad
  • 1,664
  • 2
  • 17
  • 36
  • I am not sure if I get you right. I am newbie ;) I have no popover property or assign it. From a UIButton I drag in storyboard to another ViewController and choose popover as segue. I solved my problem in a different way. In my popover there is a UiTextfield and I needed to save the String when the user dismisses the popover. I achieved it by listening to textfieldDidEndEditing. This is working for me and solved my problem, anyways I could not get popoverDidDissmiss get called... Thx for help ! – irie Oct 22 '14 at 03:05
0

You should probably use UIPopoverControllerDelegate and the method

popoverControllerDidDismissPopover:

to accomplish what you need.

Adis
  • 4,512
  • 2
  • 33
  • 40
0

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:
JapCon
  • 418
  • 5
  • 10