iPad開發 UIPopoverController 02

        常見報錯ios

在popover的使用過程當中,常常會遇到這個錯誤app

-[UIPopoverController dealloc] reached while popover is still visible.atom

錯誤的大致意思是:popover在仍舊可見的時候被銷燬了(調用了dealloc)spa

 

從錯誤能夠得出的結論代理

當popover仍舊可見的時候,不許銷燬popover對象code

在銷燬popover對象以前,必定先讓popover消失(不可見)對象

 

      經過內容控制器設置內容尺寸get

內容控制器能夠自行設置本身在popover中顯示的尺寸it

在iOS 7以前io

@property (nonatomic,readwrite) CGSize contentSizeForViewInPopover;

 

從iOS 7開始

@property (nonatomic) CGSize preferredContentSize;

以上屬性都是UIViewController的

          經常使用屬性

代理對象

@property (nonatomic, assign) id <UIPopoverControllerDelegate> delegate;

 

是否可見

@property (nonatomic, readonly, getter=isPopoverVisible) BOOL popoverVisible;

 

箭頭方向

@property (nonatomic, readonly) UIPopoverArrowDirection popoverArrowDirection;

 

關閉popover(讓popover消失)

- (void)dismissPopoverAnimated:(BOOL)animated;

 

    防止點擊UIPopoverController區域外消失

默認狀況下

只要UIPopoverController顯示在屏幕上,UIPopoverController背後的全部控件默認是不能跟用戶進行正常交互的

點擊UIPopoverController區域外的控件,UIPopoverController默認會消失

 

要想點擊UIPopoverController區域外的控件時不讓UIPopoverController消失,解決辦法是設置passthroughViews屬性

@property (nonatomic, copy) NSArray *passthroughViews;

這個屬性是設置當UIPopoverController顯示出來時,哪些控件能夠繼續跟用戶進行正常交互。這樣的話,點擊區域外的控件就不會讓UIPopoverController消失了

        如何iPhone中實現popover的效果

 

UIPopoverController這個類是隻能用在iPad中的

要想在iPhone中實現popover效果,必須得自定義view,能夠參考

http://code4app.com/ios/Popover-View-in-iPhone/4fa931bd06f6e78d0f000000

http://code4app.com/ios/Popup-Menu/512231ac6803fa9e08000000

相關文章
相關標籤/搜索