解雇UIpopover [英] Dismissing a UIpopover

查看:120
本文介绍了解雇UIpopover的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从导航堆栈中解除弹出窗口。我有一个导航控制器作为弹出窗口的根控制器和堆栈中的2个taes vies。这样第一个表视图就会推动第二个,第二个应该忽略popover。虽然这似乎是错误的,但我可以将表格中的引用传递给popover。在浏览不同的控制器后解除弹出窗口的首选方法是什么?

How do you dismiss a popover from within a navigation stack. I have a navigation controller as the root controller of the popover and 2 taes vies in the stack. So that the first table view pushes the second and the second should dismiss the popover. I could pass a reference from table to table of the popover though this seems wrong. What is the preferred way of dismissing a popover after navigated through different controllers?

推荐答案

在你的appdelegate中,添加一个新的NSNotificationCenter观察者:

In your appdelegate, add a new NSNotificationCenter observer:

[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(hidePopover)
name:@"hidePopover"
object:nil];

完成设置后,在appdelegate中添加一个新方法,如下所示:

Once you have that setup, add a new method within the appdelegate like so:

-(void)hidePopover{
    [UIPopoverController dismissPopoverAnimated:YES];
}

这种方法很棒,因为现在你设置的东西可以关闭来自任何地方的popover。你这样做:

This approach is great, because now you have things set up in such a way that you can close the popover from anywhere. You do this like so:

[[NSNotificationCenter defaultCenter] postNotificationName:@"hidePopover" 
object:nil];

希望这能解决你的难题,

Hope this solves your conundrum,

Zane

这篇关于解雇UIpopover的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆