设置内容控制器有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消失了