2012-08-14 58 views
0

當我點擊按鈕時彈出窗口正常顯示。當ipad方向改變時,UIPopoverController消失

當方向改變時,它消失&留下一個黑色的上條。

以下是參考圖片。

任何人都可以提出,它爲什麼會發生?

enter image description here

enter image description here

我的代碼:

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

回答

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; 
} 
+0

我不想刪除popover。 – iDilip 2012-08-14 12:46:31

+0

那你想做什麼? – 2012-08-14 13:04:51