Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to dismiss popovers in iOS 5?

I have a PatientTableViewController in the master side of the iPad that has a button for Adding a new patient. It transitions to this NewPatientViewController via a popover segue.

In the NewPatientViewController I have a Done button that delegates back to the PatientTableViewController:

- (void)newPatientViewController:(NewPatientViewController *)sender withZipCode:(NSNumber *)zipCode andFirstName:(NSString *)firstName andLastName:(NSString *)lastName
{
    [self dismissViewControllerAnimated:YES completion:NULL];
    [self dismissModalViewControllerAnimated:YES];
    [sender dismissModalViewControllerAnimated:YES];
    [sender dismissViewControllerAnimated:YES completion:NULL];
}

None of the methods I tried above work. However, if I use a Modal segue, everything works fine. Wat?

like image 735
Flaviu Avatar asked Jan 17 '23 12:01

Flaviu


2 Answers

Finally figure it out with the help of this post

Basically, you need to have a variable keep track of the segue (which you need to cast into a UIStoryboardPopoverSegue) and little more weirdness.

I wrote a blog post describing the solution in more detail.

like image 123
Flaviu Avatar answered Jan 25 '23 03:01

Flaviu


Did you try dismissPopoverAnimated: on UIPopoverController class?

like image 39
colbadhombre Avatar answered Jan 25 '23 05:01

colbadhombre