I am creating the application for iPad with the UIPopover. I have a main view from which I am calling two popovers displaying different information. I was following the guidelines in How to Dismiss a Storyboard Popover thread and another threads, everything works fine except one thing. In my popover I have a button which triggers an action on the parent view. From time to time the action is triggered more than once even if the button was clicked just once and also popover was opened just once. My first assumption was that the popover was caching some data from several calls, but the problem seems to appear just randomly.
My configuration is: Mac OSx Snow Leopard with Xcode 4.2, iOS 5.0. Tested in Simulator, iPad 5.1 and iPad 6.0 all the same results.
I have the main view View 1 and the popover view View 2
In my view 2 I have a method ProceedButtonClicked which sends the notification to the View 1
- (IBAction) ProceedButtonClicked{
[[NSNotificationCenter defaultCenter] postNotificationName:@"proceedButtonClicked" object:self];
}
The method is binded to the button in the popover view. In view1 (parent view):
- (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];
}
I am pretty new to the iPad development, so maybe I am missing in my code something obvious, but searching until now resulted to nothing. Any help would be appreciated. Thank you.