IOS开发iosiOS 开发

ios UIAlertController 使用ipad和iph

2015-07-06  本文已影响6431人  iCloudEnd

UIAlertController 在ipad中需要配置一下挂靠的控件,而在iphone却不需要的。

下面代码可以适配

UIAlertController *alert = [UIAlertController
                alertControllerWithTitle:NSLocalizedString(@"分组管理",nil)
                message:[NSString stringWithFormat:NSLocalizedString(@"分组:%@,  请选择您要进行的操作",nil),title]
                preferredStyle:UIAlertControllerStyleActionSheet
                ];



if([EzSystemInfo isDevicePad])
    {
        UIPopoverPresentationController *popPresenter = [alert
                                                         popoverPresentationController];
        popPresenter.sourceView = cell;
        popPresenter.sourceRect = cell.bounds;
        [self presentViewController:alert animated:YES completion:nil];
    }
    else
        [self presentViewController:alert animated:YES completion:nil];       

上一篇下一篇

猜你喜欢

热点阅读