簡體   English   中英

當ipad方向更改時,UIPopoverController消失

[英]UIPopoverController disappears when ipad orientation changes

當我單擊按鈕時,彈出窗口會正確顯示。

當方向改變時,它消失並留下黑色的頂欄。

下面是參考圖像。

誰能建議,為什么會這樣?

在此處輸入圖片說明

在此處輸入圖片說明

我的代碼:

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];

對於以下代碼有助於解決您的問題。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM