报错信息:

Your application has presented a UIAlertController (<UIAlertController: 0x100b790f0>) of style UIAlertControllerStyleActionSheet. The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.
复制代码

ActionSheet样式弹框:

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"title" message:@"message" preferredStyle:UIAlertControllerStyleActionSheet];UIAlertAction *action = [UIAlertAction actionWithTitle:@"act1" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {}];UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"act2" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {}];UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"cancle" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {}];[alert addAction:action];[alert addAction:action2];[alert addAction:cancle];[self presentViewController:alert animated:YES completion:nil];
复制代码

设置仅在iPhone: 路径: TARGETS -> Development Info -> Devices

上面创建UIAlertControllerStyleActionSheet样式弹框的代码在iPhone手机上运行时没有问题,运行效果如图(四周存在黑边是因为Xcode设置仅在iPhone运行 而模拟器放在了iPad上不适配所致): 此时可看到UIAlertControllerStyleActionSheet运行效果iPhone与iPad效果一致.

设置Universal:

设置机型为Universal(即: 手机和iPad均支持) 在iPhone上运行效果与上一致,而在iPad上运行时 导致崩溃

解决:

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"title" message:@"message" preferredStyle:UIAlertControllerStyleActionSheet];UIAlertAction *action = [UIAlertAction actionWithTitle:@"act1" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {}];UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"act2" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {}];UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"cancle" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {}];[alert addAction:action];[alert addAction:action2];[alert addAction:cancle];UIPopoverPresentationController *popover = alert.popoverPresentationController;if (popover){popover.sourceView = self.view;popover.sourceRect = CGRectMake(0, 0, 100, 100);popover.permittedArrowDirections = UIPopoverArrowDirectionAny;}[self presentViewController:alert animated:YES completion:nil];
复制代码

Your application has presented a UIAlertController (UIAlertController: 0x100b79相关推荐

  1. UIAlertController在iPad上闪退问题

    一直在使用UIAlertController,但是真没注意在iPad上和iPhone上的不同,直到在iPad上发现了个闪退情况. 1.使用 __weak typeof(self)weakSelf = ...

  2. iOS警报– UIAlertController

    In this tutorial, we'll be discussing the UIAlertController class and how it is handy to create diff ...

  3. iOS - UIAlertController

    前言 NS_CLASS_AVAILABLE_IOS(8_0) @interface UIAlertController : UIViewController@available(iOS 8.0, *) ...

  4. 【UIKit】UIAlertController使用

    官网文档:UIAlertController UIAlertController主要作为系统弹出提示功能,常用语弹出提示信息,但是可惜的是能自定义性差. 基本使用 1. 创建弹窗控制器 // 创建弹窗 ...

  5. swift怎么调用Java,Swift完成UIAlertController的调用

    Swift完成UIAlertController的调用 iOS8中的UIAlertView和UIActionSheet已经都被UIAlertViewController代替了,所以,本篇blog就来探 ...

  6. iOS开发人员:事实上你还有非常多东西须要学

    iOS 新特性总结(since iOS6) iOS 6 1.废除viewDidUnLoad 收到内存警告须要到didReceiveMemoryWarning中处理 [小技巧] -(void)didRe ...

  7. iOS开发者:其实你还有很多东西需要学

    iOS6-10新特性总结 iOS 6 1.废除了viewDidUnload,viewDidUnload 收到内存警告需要到didReceiveMemoryWarning中处理 [小技巧]: iOS6以 ...

  8. ios 系统更新特性

    iOS6-10新特性总结 iOS 6 1.废除了viewDidUnload,viewDidUnload 收到内存警告需要到didReceiveMemoryWarning中处理 [小技巧]: iOS6以 ...

  9. swift3.0UIAlertController使用方法

    let alertVC : UIAlertController = UIAlertController.init(title: "添加照片", message: "&qu ...

  10. swift3.0最新拨打电话方法

    let alertVC : UIAlertController = UIAlertController.init(title: "是否拨打报警电话:10086", message: ...

最新文章

  1. vb.net 设置打印纸张与页边距_文字办公—Word文档如何设置装订线
  2. 万字解读 | SaaS 行业,如何衡量与优化关键指标?
  3. Could not create JarEntryRevision
  4. STL-容器库101--array【C11】
  5. 图论+dp poj 1112 Team Them Up!
  6. mysql新建数据库数据类型_数据库Mysql的学习(二)-数据类型和创建
  7. 【前端】弹出框提交表单
  8. H5表单中时间日期控件
  9. 利用图形制作个人简历,图形与形状
  10. 巧用 CSS 实现炫彩三角边框动画
  11. 常见WAF_WEB应用防火墙_运维必备_应用安全
  12. Dubbo Monitor 分析
  13. 依赖倒置、控制反转、依赖注入
  14. sigmod函数求导
  15. 使用SAP的中国公司
  16. 微信小程序 - 自定义组件中类似页面 onShow 的页面显示就触发的生命周期钩子函数(页面回退时更新数据常用, 例如回退页面更新子组件数据, 回退更新子组件中 data 内容)
  17. 这8种恶心虫子 你可能每天都在吃!
  18. WinForm在窗体中嵌入窗体
  19. 计算机图形学绪论:感知、光、颜色和数学
  20. python画pr曲线_python 画函数曲线示例

热门文章

  1. 深度至尊 GHOST XP SP3 纯净版 V4.0
  2. 2022-2028年中国高尔夫行业市场现状分析及投资前景评估报告
  3. nginx获取第三方ngixn中请求头信息以及判断是否有参数的跳转地址
  4. python爬取某音乐歌词,将内容保存制作词云图
  5. clip gradient
  6. 《硅谷增长黑客实战笔记》读书笔记(一)
  7. 【基于IPD的产品开发体系】推行实践
  8. 安卓 魔窗SDK 快速接入
  9. woc,又一个大佬辞职了……
  10. 数字转换成英语的程序(c++实现)