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

最新文章

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

热门文章

  1. 树莓派.系统.修改声音输出通道(auto,hdmi,耳机接口)
  2. linux安装redis-3.0.7
  3. LeetCode 62. Unique Paths(所有不同的路径)
  4. python参考手册一书笔记之第一篇上
  5. 启动hadoop的命令
  6. Photoshop 学习中
  7. python基础知识——基于python3.6
  8. AJAX 笔记
  9. POI/Excel/HTML单元格公式问题
  10. 基于webpack搭建的vue+element-ui框架