由于从UIImagePickerController中的免费列表中排出的指针签名,因此应用程序崩溃了



我在 uiimagePickerController 选择中面临问题。当我从照片库中选择源时,由于>从免费列表中排出的指示而导致的无效签名。然后,如果我再次运行,则可以通过相同的代码工作正常。我在Google上搜索,发现了一个与我的查询Xcode有关的问题 - 我的应用程序崩溃,错误是"从免费列表中脱水的"无效的指针" ***设置了Malloc_error_break中的断点到Debug"。

但解决方案在我的情况下无法使用。

我正在使用Xcode 8.1,而我的部署目标是8.0。

as @luke请求UIImagePickerViewController的代码:

    let pickerView = UIImagePickerController()
    pickerView.delegate = self
    pickerView.allowsEditing = true
    pickerView.sourceType = .photoLibrary
    let authStatus = PHPhotoLibrary.authorizationStatus() // Get the current authorization state.
    // print(authStatus)

    if (authStatus == PHAuthorizationStatus.notDetermined) {
        // Access has not been determined.
        PHPhotoLibrary.requestAuthorization({ (newStatus) in
            if (newStatus == PHAuthorizationStatus.authorized) {
                self.present(pickerView, animated: true, completion: { _ in })
            }
            else {
            }
        })
    } else if authStatus == PHAuthorizationStatus.authorized {
        print("Access has been granted.")
        self.present(pickerView, animated: true, completion: { _ in })
    }  else if (authStatus == PHAuthorizationStatus.denied) {
        print("Access has been denied.")
    }
    else if (authStatus == PHAuthorizationStatus.restricted) {
        print("Restricted access - normally won't happen.")
    }

现在,当用户选择特定图像时:此方法将被称为:

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
    //print(info)
    if let pickedImage = info[UIImagePickerControllerEditedImage] as? UIImage {
            YOUR_GLOBAL_IMAGE_VIEW?.contentMode = .scaleAspectFit
            YOUR_GLOBAL_IMAGE_VIEW?.image = pickedImage
        }
    }
    dismiss(animated: true, completion: nil)
}

不要忘记导入PhotosUIUIImagePickerControllerDelegate

相关内容

  • 没有找到相关文章

最新更新