Your application has presented a UIAlertController (UIAlertController: 0x100b79
报错信息:
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相关推荐
- UIAlertController在iPad上闪退问题
一直在使用UIAlertController,但是真没注意在iPad上和iPhone上的不同,直到在iPad上发现了个闪退情况. 1.使用 __weak typeof(self)weakSelf = ...
- iOS警报– UIAlertController
In this tutorial, we'll be discussing the UIAlertController class and how it is handy to create diff ...
- iOS - UIAlertController
前言 NS_CLASS_AVAILABLE_IOS(8_0) @interface UIAlertController : UIViewController@available(iOS 8.0, *) ...
- 【UIKit】UIAlertController使用
官网文档:UIAlertController UIAlertController主要作为系统弹出提示功能,常用语弹出提示信息,但是可惜的是能自定义性差. 基本使用 1. 创建弹窗控制器 // 创建弹窗 ...
- swift怎么调用Java,Swift完成UIAlertController的调用
Swift完成UIAlertController的调用 iOS8中的UIAlertView和UIActionSheet已经都被UIAlertViewController代替了,所以,本篇blog就来探 ...
- iOS开发人员:事实上你还有非常多东西须要学
iOS 新特性总结(since iOS6) iOS 6 1.废除viewDidUnLoad 收到内存警告须要到didReceiveMemoryWarning中处理 [小技巧] -(void)didRe ...
- iOS开发者:其实你还有很多东西需要学
iOS6-10新特性总结 iOS 6 1.废除了viewDidUnload,viewDidUnload 收到内存警告需要到didReceiveMemoryWarning中处理 [小技巧]: iOS6以 ...
- ios 系统更新特性
iOS6-10新特性总结 iOS 6 1.废除了viewDidUnload,viewDidUnload 收到内存警告需要到didReceiveMemoryWarning中处理 [小技巧]: iOS6以 ...
- swift3.0UIAlertController使用方法
let alertVC : UIAlertController = UIAlertController.init(title: "添加照片", message: "&qu ...
- swift3.0最新拨打电话方法
let alertVC : UIAlertController = UIAlertController.init(title: "是否拨打报警电话:10086", message: ...
最新文章
- vb.net 设置打印纸张与页边距_文字办公—Word文档如何设置装订线
- 万字解读 | SaaS 行业,如何衡量与优化关键指标?
- Could not create JarEntryRevision
- STL-容器库101--array【C11】
- 图论+dp poj 1112 Team Them Up!
- mysql新建数据库数据类型_数据库Mysql的学习(二)-数据类型和创建
- 【前端】弹出框提交表单
- H5表单中时间日期控件
- 利用图形制作个人简历,图形与形状
- 巧用 CSS 实现炫彩三角边框动画
- 常见WAF_WEB应用防火墙_运维必备_应用安全
- Dubbo Monitor 分析
- 依赖倒置、控制反转、依赖注入
- sigmod函数求导
- 使用SAP的中国公司
- 微信小程序 - 自定义组件中类似页面 onShow 的页面显示就触发的生命周期钩子函数(页面回退时更新数据常用, 例如回退页面更新子组件数据, 回退更新子组件中 data 内容)
- 这8种恶心虫子 你可能每天都在吃!
- WinForm在窗体中嵌入窗体
- 计算机图形学绪论:感知、光、颜色和数学
- python画pr曲线_python 画函数曲线示例