首页 > 其他 > 详细

UIPopoverController

时间:2014-01-24 03:47:41      阅读:340      评论:0      收藏:0      [点我收藏+]

iPad App里涉及到弹出窗口,经常会用到UIPopoverController。UIPopoverController的使用比较简单。

1、初始化:

- (id)initWithContentViewController:(UIViewController *)viewController;

通过contentVC来初始化popover

示例:

  TXContentViewController * contentVC  = [[TXContentViewController alloc]initWithNibName:nil bundle:nil];

    self.popoverVCA = [[UIPopoverController alloc]initWithContentViewController:contentVC];

2、弹出popover

系统提供了2种方法:

- (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated;

通过指定一块区域弹出popover

- (void)presentPopoverFromBarButtonItem:(UIBarButtonItem *)item permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated;

通过一个barButtonItem弹出popover

示例:

     [self.popoverVCA presentPopoverFromRect:CGRectMake(200, 200, 100, 100) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES] ;

demo示意图:

bubuko.com,布布扣

重要概念:

1、popover的箭头方向

skd的文档里定义如下:

typedef NS_OPTIONS(NSUInteger, UIPopoverArrowDirection) {

    UIPopoverArrowDirectionUp = 1UL << 0, //向上

    UIPopoverArrowDirectionDown = 1UL << 1, //向下

    UIPopoverArrowDirectionLeft = 1UL << 2, //向左

    UIPopoverArrowDirectionRight = 1UL << 3, //向右

    UIPopoverArrowDirectionAny = UIPopoverArrowDirectionUp | UIPopoverArrowDirectionDown | UIPopoverArrowDirectionLeft | UIPopoverArrowDirectionRight, //上下左右

    UIPopoverArrowDirectionUnknown = NSUIntegerMax

};

2、相关属性

@property (nonatomic, retain) UIViewController *contentViewController;

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

@property (nonatomic, readonly) UIPopoverArrowDirection popoverArrowDirection;

@property (nonatomic, copy) UIColor *backgroundColor NS_AVAILABLE_IOS(7_0);

demo源码见:https://github.com/tingxuan/TXUIPopoverDemo

UIPopoverController

原文:http://blog.csdn.net/tingxuan_qhm/article/details/18698367

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!