Ipad弹出UIAlertControllerStyleActionSheet时发生崩溃
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];
最新文章
- Linux进程间通信(三):匿名管道 popen()、pclose()、pipe()、close()、dup()、dup2()
- 介绍一个非常好用的跨平台C++开源框架:openFrameworks
- hbase基础-系统架构
- 公共事件处理函数js库
- 【linux】——FreeBSD 建立 SSH 连接慢的解决方法
- MongoDB学习(一)简介
- JSBinding + SharpKit / 实战:转换 Stealth
- hdu 1255 覆盖的面积(线段树 面积 交) (待整理)
- 【转发】SSH无密码登录的配置
- VS2010下测试程序性能瓶颈
- hibernate5使用注解遇到的问题
- Redis保证事务一致性,以及常用的数据结构
- 归并排序&;&;归并排序求逆序对
- mysql性能排查思路
- Flask 三方组件 WTForms
- VMware安装步骤既常见问题
- linux内核分析ELF文件分析实践报告
- 第18月第22天 机器学习first
- 基于mindwave脑电波进行疲劳检测算法的设计(1)
- c++ strcmp strcpy sprintf