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];
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];
相关文章推荐
- iOS8下,使用UIAlertControllerStyleActionSheet时发生崩溃,怎么办?
- iPad适配UIAlertController的UIAlertControllerStyleActionSheet的崩溃问题
- iOS开发Debug之UIAlertViewController在iPad弹出崩溃问题
- UIAlertControllerStyleActionSheet 点击空白处不隐藏问题
- Xcode9学习笔记31 - 动作表样式警告窗口的使用(包含3个选项)UIAlertControllerStyle.actionSheet
- 'UIAlertController can only have one action with a style of UIAlertActionStyleCancel'
- UIAlertController UIAlertAction (UIAlertView, UIActionSheet)
- UIAlertController UIAlertAction (UIAlertView, UIActionSheet)(最好)
- ActionSheet 显示在 UIWindow,弹出又消失了解决办法
- iPad UIPopoverController弹出窗口的位置和坐标
- ios UIAlertActionStyle样式
- UIAlertController  VS  UIAlertView and UIActionSheet
- 用系统的UIAlertAction弹出相册和拍照按钮
- IOS UIAlertController 弹框 (ios 9.0 后代替了UIAlertView弹框 和 UIActionSheet下弹框)
- IOS UIAlertController 弹出框中添加视图(例如日期选择器等等)
- ionic之 ActionSheetController
- Android 日常封装之暴力CustomActionSheet自定义Fragment从底部弹出界面
- 找到多个与名为“xxx”的控制器匹配的类型。如果为此请求(“{controller}/{action}/{id}”)提供服务的路由没有指定命名空间以搜索与此请求相匹配的控制器,则会发生这种情况。
- iOS alertController之actionsheet样式添加控件(类似自定义actionsheet)
- UIActionSheet/ UIAlaterView/UIAlertController