1

我面临一个奇怪的问题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。

有没有人遇到过这个问题?任何帮助将不胜感激。

更新:我尝试关闭并重新打开弹出框。它也没有工作:

- (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];
}
4

1 回答 1

0

我现在已经修复了实施存在问题并且它有效。我们有 UIButtons 而不是 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];
于 2013-10-09T12:50:23.040 回答