首页 > 解决方案 > 收到错误:不推荐使用“UIAlertView”:在 iOS 9.0 中首先不推荐使用 - UIAlertView 已弃用

问题描述

我正在用 Flutter 开发一个移动应用程序。我在 Android 中实现了该应用程序,但我被 iOS 困住了。我有这个错误消息,我不知道如何修复。

插件 Geolocator 出现此错误。

- (void)showCamera {
  @synchronized(self) {
    if (_imagePickerController.beingPresented) {
      return;
    }
  }
  // Camera is not available on simulators
  if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] &&
      [UIImagePickerController isCameraDeviceAvailable:_device]) {
    _imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
    _imagePickerController.cameraDevice = _device;
    [[self viewControllerWithWindow:nil] presentViewController:_imagePickerController
                                                      animated:YES
                                                    completion:nil];
  } 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' 已弃用:首先在 iOS 9.0 中弃用 - UIAlertView 已弃用。将 UIAlertController 与首选样式 UIAlertControllerStyleAlert 一起使用'

标签: iosflutteruialertview

解决方案


推荐阅读