iOS   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了崩溃!UIAlertController 引起的崩溃大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

UIAlertController 使用方法很简单,下面贴简单的使用方法

UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    
    [alert addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        [self openCamera];
        
    }]];
    
    [alert addAction:[UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        [self openAlbum];
        
    }]];
    
    [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        APPLog(@"取消");
    }]];
    
   
    [self presentViewController:alert animated:YES completion:nil];

 

但是有个要注意的小细节,这么写在iPhone上没有一点问题,但是!!!!在iPad上的时候就会闪退,你需要设置他的另外两个属性,下面贴方法

 alert.popoverPresentationController.sourceView = self.view;
    alert.popoverPresentationController.sourceRect = CGRectMake(0,kScreenHeight - 70,kScreenWidth,70);

 ,这样在iPad上就不会闪退喽。

 

Mark-------------------

大佬总结

以上是大佬教程为你收集整理的崩溃!UIAlertController 引起的崩溃全部内容,希望文章能够帮你解决崩溃!UIAlertController 引起的崩溃所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: