您的位置:首页 > 产品设计 > UI/UE

Ipad弹出UIAlertControllerStyleActionSheet时发生崩溃

2017-09-26 11:20 1136 查看
pad弹出UIAlertControllerStyleActionSheet时,在iphone上运行正常,但在ipad上崩溃,解决代码如下:

UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:@"请选择图片" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];

if (isiPad) {//判断是否为ipad

UIPopoverPresentationController *popover = alertVc.popoverPresentationController;

if (popover) {

popover.sourceView = view;//视图中的某个view

popover.sourceRect = view.bounds;

popover.permittedArrowDirections = UIPopoverArrowDirectionDown;//alertVC弹出的位置

}

}

UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

}];

UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"相册" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

}];

UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {

[alertVc dismissViewControllerAnimated:YES completion:nil];

}];

[alertVc addAction:action1];

[alertVc addAction:action2];

[alertVc addAction:action3];

[self presentViewController:alertVc animated:YES completion:nil];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐