zoukankan      html  css  js  c++  java
  • 崩溃!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-------------------

  • 相关阅读:
    redis安装
    VMware安装Centos
    Nacos简单配置
    RAS非对称加密
    uLua Unity工作机制
    一个长期主义者的内与外
    MacOSX 运行Unity卡顿 [gethostname]
    着眼于长远,走的更稳
    物质趋于无穷, 人群趋于发散.符合熵增加的规律
    论PM与团队与敏捷开发
  • 原文地址:https://www.cnblogs.com/110-913-1025/p/9198368.html
Copyright © 2011-2022 走看看