ios UIAlertController 使用ipad和iphone

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];       

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容