簡體   English   中英

UIPopOverController在旋轉時丟失內容

[英]UIPopOverController losing content when rotating

我的UIPopOverController有時會丟失其內容,當被旋轉(不可再現)或者例如我從橫向的tableview中打開一些內容時,將設備旋轉為肖像,然后以縱向打開相同的內容。

顯示Popovercontroller但沒有內容可見,即它是黑色....有沒有人偶然發現這個或類似的東西?

在旋轉發生后使用UIPopoverController時遇到了類似的問題(UIPopoverController的大小奇怪地改變了,它將自己重新定位到屏幕中的奇怪位置等)。

對我有用的技巧是在應用程序中重載UIViewController的didRotateFromOrientation:(UIInterfaceOrientation)方法。 因此,在顯示UIPopoverController時顯示的應用程序的UIViewController類重載該方法,並從那里再次調用UIPopoverController的presentPopoverFromRect:方法:

-(void) didRotateFromOrientation:(UIInterfaceOrientation)uiOrientation {
    if (popoverController.popoverVisible) {
        // Define rect to be the UI component's rect where you want to tie the popoverController
        CGRect rect = CGRectMake(...);
        // This method will reposition the popover correctly
        [popoverController presentPopoverFromRect:rect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:NO];  
    }
}

請注意,如果您使用UIPopoverController的presentPopoverFromBarButtonItem:方法將UIPopoverController綁定到UIBarButtonItem,則系統應自動在旋轉后正確地定位彈出窗口。

暫無
暫無

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

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