我創造與UIPopover爲iPad應用程序。我有一個主要觀點,我正在調用兩個顯示不同信息的popovers。我是按照How to Dismiss a Storyboard Popover線程和線程的另一個準則,一切,除了一件事工作正常。在我的popover中,我有一個觸發父視圖上的操作的按鈕。即使按鈕被點擊一次,popover也會不止一次觸發,並且popover只打開一次。我的第一個假設是,popover緩存了幾次調用的一些數據,但問題似乎只是隨機出現。UIPopover按鈕重複動作
我的配置是:MAC OSX雪豹和Xcode 4.2的iOS 5.0。 經測試,在模擬器,iPad的5.1和iPad 6.0的所有相同的結果。
我有主視圖視圖1和酥料餅視圖視圖2
我認爲2我有一種方法ProceedButtonClicked它發送通知,以查看1
- (IBAction) ProceedButtonClicked{
[[NSNotificationCenter defaultCenter] postNotificationName:@"proceedButtonClicked" object:self];
}
的方法綁定到彈出視圖中的按鈕。 在廠景(父視圖):
- (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的發展,所以也許我缺少在我的代碼的東西很明顯,但搜索直到現在導致不了了之。 任何幫助,將不勝感激。 謝謝。
謝謝。我也假設內存管理不當,但我正在使用ARC,而且我不知道如何恰當地保持活動只有一個控制器。調用'popoverControllerDidDismissPopover'並設置'popOverController'到'nil'沒有幫助。我也嘗試將UIButton操作更改爲上述代碼,結果仍然相同。 –