【发布时间】:2012-11-26 19:44:31
【问题描述】:
我正在使用 UIPopover 为 iPad 创建应用程序。我有一个主视图,我从中调用两个显示不同信息的弹出框。我遵循How to Dismiss a Storyboard Popover 线程和另一个线程中的指导方针,除了一件事,一切正常。在我的弹出窗口中,我有一个按钮可以触发父视图上的操作。即使仅单击一次按钮并且仅打开了一次弹出窗口,有时也会多次触发该操作。我的第一个假设是弹出框正在缓存来自多个调用的一些数据,但问题似乎只是随机出现的。
我的配置是:Mac OSx Snow Leopard with Xcode 4.2, iOS 5.0。 在模拟器、iPad 5.1 和 iPad 6.0 中测试的结果都一样。
我有主视图 View 1 和弹出视图 View 2
在我的视图 2 中,我有一个 ProceedButtonClicked 方法,它将通知发送到视图 1
- (IBAction) ProceedButtonClicked{
[[NSNotificationCenter defaultCenter] postNotificationName:@"proceedButtonClicked" object:self];
}
该方法绑定到弹出视图中的按钮。 在 view1(父视图)中:
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ButtonClicked:) name:@"proceedButtonClicked" object:nil];
}
- (void) ButtonClicked:(NSNotification *) notification {
NSLog(@"I'm here ...");
//dismiss popover
if (paramPopover)
[paramPopover dismissPopoverAnimated:YES];
}
我对 iPad 开发还很陌生,所以我的代码中可能缺少一些明显的东西,但是直到现在搜索都没有结果。 任何帮助,将不胜感激。 谢谢。
【问题讨论】:
标签: xcode uipopovercontroller uistoryboard