我正在使用 UIStoryboardPopoverSegue
来呈现 iOS 5 iPad 应用的弹出框.Segue 效果很好,但似乎包含按钮的工具栏是弹出框控制器的直通视图,因此如果您继续按下按钮,则会出现更多弹出框.由于我自己没有创建和跟踪 UIPopoverController
(正如故事板所做的那样),当再次触摸按钮时我无法关闭它.有没有其他人遇到过这个?我向 Apple 提出了一个错误,但他们没有回应.
I'm using a UIStoryboardPopoverSegue
to present a popover for an iOS 5 iPad app. The Segue works great, but it seems like the toolbar that contains the button is a passthrough view for the popover controller so if you keep pressing the button, more popovers appear. As I'm not creating and keeping track of the UIPopoverController
myself (as the Storyboard is doing it) I can't dismiss it when the button is touched again. Has anyone else run into this? I have a bug open with Apple but they haven't responded.
编辑:我已经使用下面的答案解决了这个问题.这是我最终使用的代码.currentPopover
是我的视图控制器类中的一个 __weak
ivar,所以当控制器完成时它会自动下降到 nil.
EDIT: I've solved this using the answer below. Here is the code I ended up using. currentPopover
is a __weak
ivar in my view controller class, so when the controller is done it will drop to nil automatically.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue isKindOfClass:[UIStoryboardPopoverSegue class]]){
// Dismiss current popover, set new popover
[currentPopover dismissPopoverAnimated:YES];
currentPopover = [(UIStoryboardPopoverSegue *)segue popoverController];
}
}
您必须存储对作为 UIStoryboardPopoverSegue
类的一部分传递的 popoverController
属性的引用prepareForSegue
类方法.
You have to store a reference to the popoverController
property passed as part of the UIStoryboardPopoverSegue
class in the prepareForSegue
class method.
要访问它,请像这样覆盖调用视图控制器中的方法:
To access it, over-ride the method in the calling view controller like this:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// The Storyboard Segue is named popover in this case:
if ([segue.identifier compare:@"popover"] == NSOrderedSame) {
// segue.popoverController is only present in popover segue's
// self.seguePopoverController is a UIPopoverController * property.
self.seguePopoverController = segue.popoverController;
}
}
然后你可以用通常的方式关闭它.
Then you can dismiss it in the usual way.
这篇关于UIStoryboardPopoverSegue 在按钮触摸时打开多个窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!