UIPopoverController

1.判断设备类型

- (void)viewDidLoad{
    [super viewDidLoad];
    UIColor *clr = nil;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        clr = [UIColor colorWithRed:0.875 green:0.88 blue:0.91 alpha:1];
    } else {
        clr = [UIColor groupTableViewBackgroundColor];
    }
    
    self.view.backgroundColor = clr;
}

2.UIPopoverController

1.这个对象只能在Ipad中运行,能够在一个带边框的窗口中显示另一个视图控制对象(UIPopoverController的contentViewController属性)的视图,并且悬浮在界面的最前面。

代码如下:

   if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        imagePickerPover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
        [imagePickerPover setDelegate:self];
        
        [imagePickerPover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    }
    else{
        //会retain imagePicker
        [self presentModalViewController:imagePicker animated:YES];
    }
    [imagePicker release];
}

效果如下:

2.触摸屏幕的其他区域可以关闭UIPopoverController对象,若果该对象是通过这种方式关闭的,那么对象会向自己的delegate发送popoverControllerDidDismissPopover:消息。

- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController {
    NSLog(@"User dimissed popover");
    //发送autorelease而不是release是因为关闭时会带动画效果,
    //使用autorelease才能让动画代码有机会保留UIPopoverController对象,动画结束后才释放
    [imagePickerPover autorelease];
    imagePickerPover = nil;
}

3.也可以向对象发送dismissPopoverAnimated:消息来关闭对象,用这种方式关闭对象时则不会向自己的delegate发送popoverControllerDidDismissPopover:消息。

3.dismissModalViewControllerAnimated:消息
在UIViewController对象收到dismissModalViewControllerAnimated:消息时,会检查自己的modalViewController属性,如果是nil,就会将该消息转发给自己的parentViewController。
设置模态视图样式:[navController setModalPresentationStyle:];
设置模态视图弹出关闭动画:[navController setModalTransitionStyle:];

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值