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

时间:2021-03-13 12:09:46

标签: ios flutter uialertcontroller

    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' 仍然收到不同的错误。

1 个答案:

答案 0 :(得分:0)

您可以在 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];