'UIAlertView' 已弃用:首先在 iOS 9.0 中弃用

问题描述

    else {
        [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error",nil)
                                    message:NSLocalizedString(@"Camera not available.",nil)
                                   delegate:nil
                          cancelButtonTitle:NSLocalizedString(@"OK",nil)
                          otherButtonTitles:nil] show];
        self.result(nil);
        self.result = nil;
        _arguments = nil;
      }

}

我收到此错误,我尝试将 'UIAlertView' 更改为 'UIAlertController' 仍然收到不同的错误

解决方法

您可以在 xCode 构建中使用以下 UIAlertController 替换:

UIAlertController *alert = [UIAlertController 
alertControllerWithTitle:@"Error" message:@"Camera not available" 
preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *ok = [UIAlertAction actionWithTitle:@"Ok" style: style:UIAlertActionStyleDefault handler:nil];


[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...