I am facing a weird issue with UIPopoverController
. While creating the popover, we have set passthrough views property. We wanted to popover to close if we tap anywhere outside it.
[self.popover presentPopoverFromBarButtonItem:barButtonItemView
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
// comment the below line if only toggle feature is expected to close the popover
[self.popover setPassthroughViews:self.tileMenu.tileMenuButtonsArray];
It works fine untill device's orientation changes. after orientation change, tapping outside has no effect. The method - popoverControllerShouldDismissPopover
- is never called after orientation changes. If I tap on the button again, then it starts working fine. i.e. it relaunches the popover and closes the popover if i tap outside.
I am working on IOS 7 now.
Has anyone faced this issue before? any help will be appreciated.
Update: I tried dismissing and reopening the popover. It didn't work as well:
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration
{
if ( [self.popover isPopoverVisible] )
{
[self.popover dismissPopoverAnimated:NO];
self.reopenPopover = YES;
}
}
-(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if (self.reopenPopover) {
[self presentPopover:self.selectedTileMenuBarButtonItem];
}
self.reopenPopover = NO;
}
-(void) presentPopover:(UIBarButtonItem *) barButtonItemView {
self.selectedTileMenuBarButtonItem = barButtonItemView;
[self.popover presentPopoverFromBarButtonItem:barButtonItemView
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
// comment the below line if only toggle feature is expected to close the popover
[self.popover setPassthroughViews:self.tileMenu.tileMenuButtonsArray];
}