UIPopoverController
我面临一个奇怪的问题。在创建弹出窗口时,我们设置了passthrough views属性。如果我们点击它以外的任何地方,我们想要关闭。
[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];
它工作正常,直到设备的方向更改。方向改变后,外部敲击无效。方法- popoverControllerShouldDismissPopover
- 在方向更改后永远不会被调用。如果我再次点击按钮,它就会开始正常工作。即如果我点击外面,它会重新启动弹出窗口并关闭弹出窗口。
我正在研究IOS 7.
以前有人遇到过这个问题吗?任何帮助将不胜感激。
更新: 我试图解雇并重新打开popover。它不起作用:
- (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];
}
答案 0 :(得分:0)
我已经修复了实施的问题并且它有效。
我们有UIButton而不是UIBarButton,但是由于方法presentPopoverFromRect
的一些早期问题(当ipad的方向发生变化时出现了问题),我们以这种方式呈现了弹出窗口:
UIButton *control = (UIButton *) sender;
UIBarButtonItem *barButtonItemView = [[UIBarButtonItem alloc] init];
[barButtonItemView setCustomView:control];
[self.popover presentPopoverFromBarButtonItem:barButtonItemView permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
不需要。以下代码修复了问题:
[self.popover presentPopoverFromRect:[sender bounds] inView:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
// comment the below line if only toggle feature is expected to close the popover
[self.popover setPassthroughViews:self.tileMenu.tileMenuButtonsArray];