How to dismiss popovers in iOS 5?

烈酒焚心 提交于 2019-12-23 14:03:44

问题


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?


回答1:


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.




回答2:


Did you try dismissPopoverAnimated: on UIPopoverController class?



来源:https://stackoverflow.com/questions/9253878/how-to-dismiss-popovers-in-ios-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!