iOS开发中UIPopoverController的使用详解

2020-01-14 17:18:36王旭

    //说明:popover会指向sender.bounds这一块矩形框,这块矩形框以sender的左上角为坐标原点
    //注意:注意sender.frame和sender.bounds的区别
    
}
@end


界面效果:(部分)

 

iOS开发中UIPopoverController的使用详解

关于frame坐标计算的图示:

iOS开发中UIPopoverController的使用详解

下面两者是等价的:

iOS开发中UIPopoverController的使用详解

即如果想让箭头指向某一个UIView的做法有2种做法,比如指向一个button

方法1

复制代码
  [popover presentPopoverFromRect:button.bounds inView:button permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
方法2
复制代码
  [popover presentPopoverFromRect:button.frame inView:button.superview permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
六、设置代理

 

代理对象

复制代码
  @property (nonatomic, assign) id <UIPopoverControllerDelegate> delegate;
是否可见
复制代码
  @property (nonatomic, readonly, getter=isPopoverVisible) BOOL popoverVisible;
箭头方向
复制代码
  @property (nonatomic, readonly) UIPopoverArrowDirection popoverArrowDirection; 
关闭popover(让popover消失)
复制代码
  - (void)dismissPopoverAnimated:(BOOL)animated;