0

当我单击按钮时,弹出框会正确显示。

当方向改变时,它会消失并留下一个黑色的顶栏。

下面是参考图片。

任何人都可以建议,为什么会这样?

在此处输入图像描述

在此处输入图像描述

我的代码:

EBFirstViewController *firstViewController = [[EBFirstViewController alloc]init];
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:firstViewController];
    navigationController.delegate = self;

    UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:navigationController];
    self.popoverController = popover;
    popoverController.delegate = self;

    [popoverController setPopoverContentSize:CGSizeMake(320.0f, 527.0f)];
    [popoverController presentPopoverFromRect:settingsBtn.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
4

1 回答 1

0

对于以下代码有助于解决您的问题。

- (void)application:(UIApplication *)application willChangeStatusBarOrientation:(UIInterfaceOrientation)newStatusBarOrientation duration:(NSTimeInterval)duration {
    // a cheat, so that we can dismiss all our popovers, if they're open.

    if (ObjPopover) {
        // if we're actually showing the menu, and not the about box, close out any active menu dialogs too
        if (menuPopoverVC && menuPopoverVC == ObjPopover.contentViewController)
            [menuPopoverVC.popoverController dismissPopoverAnimated:YES];
        [menuPopoverPC dismissPopoverAnimated:YES];
        menuPopoverPC = nil;
    }
}


- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController {
    // the user (not us) has dismissed the popover, let's cleanup.
    ObjPopover = nil;
}
于 2012-08-14T12:21:16.967 回答