設置內容控制器有3種方法:web
2.@property (nonatomic, retain) UIViewController *contentViewController;ide
3.- (void)setContentViewController:(UIViewController *)viewController animated:(BOOL)animated;動畫
設置顯示的位置有兩種方法:atom
animated :是否經過動畫顯示出來url
2.圍繞着某一塊特定區域顯示(箭頭指定那塊特定區域)spa
(void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated;3d
rect :指定箭頭所指區域的矩形框範圍(位置和尺寸)代理
view :rect參數是以view的左上角爲座標原點(0,0)code
arrowDirections :箭頭的方向對象
animated :是否經過動畫顯示出來
在popover的使用過程當中,常常會遇到這個錯誤 -[UIPopoverController dealloc] reached while popover is still visible. 錯誤的大致意思是:popover在仍舊可見的時候被銷燬了(調用了dealloc)
從錯誤能夠得出的結論:
內容控制器能夠自行設置本身在popover中顯示的尺寸
代理對象 @property (nonatomic, assign) id 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消失,解決辦法是設置passthroughViews屬性 @property (nonatomic, copy) NSArray *passthroughViews; 這個屬性是設置當UIPopoverController顯示出來時,哪些控件能夠繼續跟用戶進行正常交互。這樣的話,點擊區域外的控件就不會讓UIPopoverController消失了