118

我正在尝试在 UIImageView 中显示照片库中的图像

完整的错误是:

2017-06-09 21:55:59.063307+0200 firstapp2.0[12873:1120778] PhotoPicker 发现错误:错误域=PlugInKit 代码=13“查询已取消”用户信息={NSLocalizedDescription=查询已取消}

我的代码包括在下面:

import UIKit

class ViewController: UIViewController,UIImagePickerControllerDelegate,UINavigationControllerDelegate{

    @IBOutlet weak var pic: UIImageView!
    @IBOutlet weak var text: UILabel!

    var chosenImage : UIImage!

    override func viewDidLoad() {
        super.viewDidLoad()        
        pic.isUserInteractionEnabled = true;
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [AnyHashable: Any]) {
        var chosenImage = info[UIImagePickerControllerEditedImage]
        self.pic!.image = chosenImage as! UIImage
        picker.dismiss(animated: true, completion: nil)
    }

    func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
        picker.dismiss(animated: true, completion: nil)
    }

    @IBAction func tap(_ sender: Any) {        
        self.text.text = "Kreason"
        let imagePicker = UIImagePickerController()    
        imagePicker.delegate = self        
        imagePicker.sourceType = UIImagePickerControllerSourceType.photoLibrary
        imagePicker.allowsEditing = false    
        self.present(imagePicker, animated: true, completion: nil)
    }
}
4

35 回答 35

39

您需要做出明确的 Objective-C 参考:@objc

@objc func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
    let chosenImage = info[UIImagePickerControllerOriginalImage] as! UIImage
    image = chosenImage
    self.performSegue(withIdentifier: "ShowEditView", sender: self)
    dismiss(animated: true, completion: nil)
}
于 2017-07-04T13:23:40.427 回答
18

我找到了这个解决方案。由于下面提到的这两个原因,我们得到了这个错误。

  1. 首先我们需要调用这个方法进行授权

授权码

func checkPermission() {
  let photoAuthorizationStatus = PHPhotoLibrary.authorizationStatus() switch photoAuthorizationStatus {
    case .authorized: print("Access is granted by user")
    case .notDetermined: PHPhotoLibrary.requestAuthorization({
      (newStatus) in print("status is \(newStatus)") if newStatus == PHAuthorizationStatus.authorized { / do stuff here */ print("success") }
    })
    case .restricted: / print("User do not have access to photo album.")
    case .denied: / print("User has denied the permission.")
  }
}
  1. 正确的方法调用方式didFinishPickingMediaWithInfo

错误的:

private func imagePickerController( picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
} 

正确的

@objc func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
} 

我希望这个解决方案能帮助你解决这个错误。

如果它对您有用,请不要忘记将其标记为正确,因此这将有助于其他人找到正确的方法。

于 2017-11-20T06:13:36.870 回答
17

我找到了!它试图告诉您您没有“照片”的授权您需要#import <Photos/Photos.h>在Objective-C中包含并请求授权,例如这样的。

希望这会为您节省一些时间。我花了整整两天时间调试这个!

[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
    switch (status) {
        case PHAuthorizationStatusAuthorized:
            NSLog(@"PHAuthorizationStatusAuthorized");
            break;
        case PHAuthorizationStatusDenied:
            NSLog(@"PHAuthorizationStatusDenied");
            break;
        case PHAuthorizationStatusNotDetermined:
            NSLog(@"PHAuthorizationStatusNotDetermined");
            break;
        case PHAuthorizationStatusRestricted:
            NSLog(@"PHAuthorizationStatusRestricted");
            break;
    }
}];

我相信有人可以告诉你如何在 Swift 中做同样的事情。

于 2017-09-23T06:14:25.413 回答
15

尝试了一些组合响应,但没有取得多大成功。

使用 Swift 4,我发现我需要确保实现以下两项,以确保选择图像并将其放入选择器(注意发现扩展时遇到的“[discovery] 错误:

错误域=PlugInKit 代码=13“查询已取消”UserInfo={NSLocalizedDescription=查询已取消}”

消息仍然显示在控制台中,但它不会阻止您添加图像)。也许这是一条导致选择器被解雇的消息?

UIImagePickerController1)的委托(UIImagePickerControllerDelegate & UINavigationControllerDelegate)?需要明确添加UINavigationControllerDelegate作为协议之一:

class ViewController:UIViewController, UIImagePickerControllerDelegate, 
    UINavigationControllerDelegate { .... }. 

2) 确保 info.plist 设置了Privacy - Photo library Usage Description键和字符串值。

当然,您需要确保创建 aUIImagePickerController并将其委托设置为等于selfin ViewDidLoad()

class ViewController:UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate { 
    let imagePickerController = UIImagePickerController()
    override func viewDidLoad() {
        super.viewDidLoad()
        imagePickerController.delegate = self
    }
    ...
}
于 2017-12-27T09:30:21.520 回答
11

XCODE 10.1 / 斯威夫特 4.2:

  1. 添加所需的权限(其他提及)

  2. 实现这个委托函数:

    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
    
        if let pickedImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
            self.imgView.contentMode = .scaleAspectFit
            self.imgView.image = pickedImage
        }
    
        dismiss(animated: true, completion: nil)
    }
    
于 2018-09-22T18:01:50.943 回答
11

我修复了这个问题,将下面的函数调用到 viewdidload 或 viewWillAppear 或 viewDidAppear 以检查您的应用程序的权限。

func checkPermission() {
        let photoAuthorizationStatus = PHPhotoLibrary.authorizationStatus()
        switch photoAuthorizationStatus {
        case .authorized:
            print("Access is granted by user")
        case .notDetermined:
            PHPhotoLibrary.requestAuthorization({
                (newStatus) in
                print("status is \(newStatus)")
                if newStatus ==  PHAuthorizationStatus.authorized {
                    /* do stuff here */
                    print("success")
                }
            })
            print("It is not determined until now")
        case .restricted:
            // same same
            print("User do not have access to photo album.")
        case .denied:
            // same same
            print("User has denied the permission.")
        }
    }

并且要使用上述方法,不要忘记import Photos在类的顶部添加。

于 2017-10-26T07:43:38.970 回答
10

* Swift 3 中缺少 DELEGATE *

在我的情况下,所有设置都是正确的:
1 - 代表( UIImagePickerControllerDelegate,UINavigationControllerDelegate );
2 - 已验证的权限;
3 - Plist 已经完成;
4 - 我读到了这个答案的所有内容;

但是我忘了实现pickerview.delegate = selfviewDidLoad 因为我从我的另一个视图控制器复制和粘贴并忘记了这一点!

我希望它对某人有所帮助,请先查看您的复制/粘贴!!!

于 2017-12-14T18:40:43.583 回答
9

This might not be the most directly helpful answer - but hopefully it will help! I'm 99% sure that this particular error message isn't actually pointing you to the real problem. I spent hours pulling my hair out over this same exact issue.

1) I had authorization for photos printing to the console when I'd launch my picker, 2) I could navigate and pick a photo easy enough, and 3) when I would return me to my view upon dismissing the picker, my button image wasn't updated with the new photo... and the only hint that I had to the problem was the exact same error message that you are receiving.

Turns out I was hard-coding a placeholder image in ViewWillAppear instead of ViewDidLoad. Every time the picker was dismissing, it was calling ViewWillAppear and replacing my chosen image with my hard coded image. I fixed that issue and sure enough - everything is working fine now... and I'm still seeing that error message every time I return from the picker.

I recommend looking somewhere other than the ImagePicker for your problem and you'll likely find it.

于 2017-12-09T18:33:40.240 回答
7

如果你还没有这样做,试试这个

产品 > 方案 > 编辑方案 > 环境变量OS_ACTIVITY_MODE: disable

它解决了我的问题。

于 2017-12-30T16:04:43.783 回答
7

这解决了 Swift 4 中的问题:

更改下面的代码

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {}

对此:

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {}


Swift 4.2 update:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]){}
于 2017-08-21T11:28:27.930 回答
6

当我试图从选择器回调中显示另一个控制器时,我收到了相同的消息imagePickerController。对我有用的解决方案是将我的代码从选择器解除方法移到完成回调中

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
        picker.dismiss(animated: true) {
            if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
                let cropController:CropViewController = CropViewController(croppingStyle: .circular, image: pickedImage)
                cropController.delegate = self
                self.present(cropController, animated: true, completion: nil)
            }
        }
    }
于 2018-09-05T19:25:32.787 回答
4

通过在设置图像时设置 1 秒延迟来修复它。

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

    if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {

        picker.dismiss(animated: false, completion: nil)
        DispatchQueue.main.asyncAfter(deadline: .now() + 1.0, execute: {
            self.discussionImage.image = image
        })
    }
}
于 2018-12-28T13:19:33.650 回答
4

确保你是两个子类:UIImagePickerControllerDelegate, UINavigationControllerDelegate.

另外,请记住设置委托:

let picker = UIImagePickerController()
picker.allowsEditing = true
picker.sourceType = .photoLibrary
picker.delegate = self  //Don't forget this line!
self.present(picker, animated: true, completion: nil)

归功于此来源

于 2018-02-04T20:36:39.553 回答
4

找到解决这个问题的方法花了我很长时间。看起来问题是找不到 UIImagePickerControllerDelegate 的函数 imagePickerController 。如果您正确设置了委托,并且在升级到 Swift 4 后它停止工作,那么问题可能是您没有使用自 Swift 4 以来必需的 @objc 使其对 Objective-C 可访问。

它一定要是:

@objc func imagePickerController(...

代替

func imagePickerController(...
于 2018-10-20T09:24:36.717 回答
3

这让我很困惑,但下面链接中的答案对我有用。错误消失,图像按预期显示

就像上面的答案之一,您必须拥有(_ picker...而且@objc在功能之前。

@objc func imagePickerController(_ picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) {
...
}

https://forums.developer.apple.com/thread/82105

于 2018-02-06T14:29:32.750 回答
3
于 2017-09-05T17:18:26.900 回答
2

这解决了我的错误:

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
    let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage
    addPhotoBtn.setImage(pickedImage, for: .normal)
    dismiss(animated: true, completion: nil)


}

func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
    dismiss(animated: true, completion: nil)

}
于 2017-11-02T08:46:25.257 回答
2

使用此代码

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any])
于 2018-10-11T12:37:12.967 回答
2

这个“Error Domain=PlugInKit Code=13”错误让很多人感到困惑,尽管它似乎是一个无害的苹果调试消息。我在获取我选择在我的 UI 中设置的图像时遇到了问题,并认为该错误是问题所在,但它有点微妙。

我将图像选择器控制器放在一个与呈现它的视图控制器分开的文件中。

MyViewController.swift

class MyViewController: UIViewController {
    @IBOutlet weak var profileImage: UIImageView!

    ...
}

extension MyViewController: ImagePickerDelegate {
    func didSelect(image: UIImage?) {
        self.profileImage.image = image
    }
}

ImagePicker.swift

open class ImagePicker: NSObject {
    ...
    private func pickerController(_ controller: UIImagePickerController, didSelect image: UIImage?) {
        controller.dismiss(animated: true, completion: {self.delegate?.didSelect(image: image)}
        )
    }
}

大多数教程和答案都将完成设置为 nil。但是,如果您将完成设置为 nil 并单独调用委托的 didSelect 方法,则该方法被调用但图像未设置,因此请确保使用关闭完成。

再说一次,我知道这个答案可能与原始问题没有直接关系,但我感觉很多人都是为了这个问题而来的,而给定的解决方案并没有帮助。原因是大多数给出答案的人都将他们的图像选择器控制器与他们的主视图控制器在同一个类中,因此不需要使用完成。

于 2019-05-24T23:00:22.523 回答
2

这就是我所做的,它解决了我的问题。

  • 添加@objc
  • 添加内部
  • 在 imagePicker 之前添加 _
  • 确保您使用的是 Any 而不是 AnyObject

希望这可以帮助!

于 2018-01-28T03:39:05.187 回答
2

请按以下步骤检查:

  1. 导入照片
  2. 有权访问专辑:

    func authorizeToAlbum(completion:@escaping (Bool)->Void) {
    
    if PHPhotoLibrary.authorizationStatus() != .authorized {
        NSLog("Will request authorization")
        PHPhotoLibrary.requestAuthorization({ (status) in
            if status == .authorized {
                DispatchQueue.main.async(execute: {
                    completion(true)
                })
            } else {
                DispatchQueue.main.async(execute: {
                    completion(false)
                })
            }
        })
    
    } else {
        DispatchQueue.main.async(execute: {
            completion(true)
        })
    }
    }
    
  3. 呈现 UIImagePickerController

    self.authorizeToAlbum { (authorized) in
        if authorized == true {
            let picker = UIImagePickerController()
            picker.delegate = self
            picker.allowsEditing = false
            picker.sourceType = .photoLibrary
    
            self.present(picker, animated: true, completion: nil)
        }
    }
    
  4. 关键步骤,确保委托方法严格遵循

    // MARK: - UIImagePickerControllerDelegate Methods
    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
    if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
        self.pickedImage = pickedImage
        if let finalImage = handleImage(originalImage: self.pickedImage!, maskImage: self.maskImage!) {
            self.imageView.image = finalImage
        }
    }
    
    dismiss(animated: true, completion: nil)
    }
    
于 2017-12-24T02:59:46.253 回答
2

在我的情况下,我收到了这个错误,因为我在没有首先验证用户是否允许访问图像的情况下展示了一个图像选择器控制器。在我的代码的其他地方,用户已授予权限,所以我认为我需要做的就是导入照片。但是,由于他们“可能”没有在应用程序中授予权限,因此在我展示图像选择器控制器为我解决问题之前添加了此权限(也可以导入照片)。

// request photos permission if permission has not been granted
    if PHPhotoLibrary.authorizationStatus() != PHAuthorizationStatus.authorized {
        PHPhotoLibrary.requestAuthorization({ (status: PHAuthorizationStatus) in

        })
    }

如果这个答案看起来多余,我很抱歉,但我必须从几个不同的答案中拼凑起来才能让我的解决方案发挥作用。也许这会帮助其他使用 Swift 4 的人。

于 2018-02-27T15:54:34.560 回答
1

我有同样的错误,我以这种方式修复它:

以不同方式获取图像对象取决于 UIImagePickerController 允许编辑是真还是假

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

    if isImagePickerAllowEditing {
        sourceImage = info[UIImagePickerControllerEditedImage] as? UIImage
    } else {
        sourceImage = info[UIImagePickerControllerOriginalImage] as? UIImage
    }

    ....

}

当然,请先请求访问照片库的权限,如上述评论。

于 2017-10-27T08:24:05.743 回答
1

最后,我的UINavigationControllerDelegate代表失踪了。

class YourViewController:UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate

于 2018-02-20T06:37:15.047 回答
1

当您没有在文件中配置使用照片库的权限时,也会发生错误Info.plist

您需要添加一个字符串Privacy - Photo Library Usage Description,该字符串将在您的应用程序第一次尝试访问用户的照片库时出现。Info.plist

最终Info.plist调整应如下所示: 在此处输入图像描述

于 2017-10-13T13:40:40.267 回答
1

就我而言,Apple Team 似乎优化并修复了快速分配内存管理。我的代码在快速更新之前一直运行良好,我发现我的“错误”是我没有保留选择器,但它已经工作了很长时间而没有保留,所以这里有一个完整的准备工作的解决方案。

// Add Privacy - Photo Library Usage Description to your info.plist
<key>NSPhotoLibraryUsageDescription</key>
<string>APPNAME need to access your pictures to violate your privacy :P</string>

import Photos    
class MyImageSelector: UIViewController,UIImagePickerControllerDelegate,UINavigationControllerDelegate {

    var picker = UIImagePickerController() 
    // Make sure to retain this picker var until the picker returned

    func checkPermission() {
        let call = self.presentAuthorized

            let photoAuthorizationStatus = PHPhotoLibrary.authorizationStatus()
            switch photoAuthorizationStatus {
            case .authorized:
                print("Access is granted by user")
                showPicker()
            case .notDetermined:
                PHPhotoLibrary.requestAuthorization({ newStatus in
                print("status is \(newStatus)")
                if newStatus == PHAuthorizationStatus.authorized {
                    /* do stuff here */
                    print("success")
                    showPicker()
                }
                })
            case .restricted:
                print("User do not have access to photo album.")
            case .denied:
                print("User has denied the permission.")
            }

    }

    func showPicker() {
        picker = UIImagePickerController()
        picker.allowsEditing = true
        picker.sourceType = .photoLibrary
        picker.delegate = self  //Don't forget this line!
        self.present(picker, animated: true, completion: nil)
    }

    @objc public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
        // DO something with picture
    }

    @objc public func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
        // User cancelled the pick
    }
}
于 2019-06-10T15:41:03.053 回答
0

尽量不要在方法内部创建 UIImagePickerController ,而是将其作为类变量并只创建一次。

当我忘记为 UIImagePickerController 设置委托时,我遇到了和你一样的问题

于 2019-06-27T05:11:47.067 回答
0

我遇到了同样的问题。上述建议都不适合我。但是,我通过显式调用 picker.dismiss 并解雇该帖子解决了这个问题。我不清楚为什么我会发出这样的解雇电话,但它对我有用。

   @objc func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

        print("Image picked")
        picker.dismiss(animated: true, completion: nil)
        dismiss(animated: true) {
            print("dismissed")
             self.delegate?.presentEditor(img: (info[UIImagePickerControllerOriginalImage] as? UIImage)!, id: self.id!)
    }

}
于 2017-09-21T12:42:10.563 回答
0

我找到了 IMage PickerView 的解决方案.....

@IBOutlet weak var myImageView: UIImageView!

var imagePicker = UIImagePickerController()


  @IBAction func selectImage(_ sender: Any) {

        let myPickerController = UIImagePickerController()
        myPickerController.delegate = self;
        myPickerController.sourceType = UIImagePickerControllerSourceType.photoLibrary

        self.present(myPickerController, animated: true, completion: nil)

    }

    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
        print(info)

        var selectedImageFromPicker: UIImage?

        if let editedImage = info["UIImagePickerControllerEditedImage"] as? UIImage
        {
            selectedImageFromPicker = editedImage as! UIImage


        }else if let originalImage = info["UIImagePickerControllerOriginalImage"] as? UIImage{

            selectedImageFromPicker = originalImage as! UIImage


        }

        dismiss(animated: true, completion: nil)

        if var selectedImage = selectedImageFromPicker
        {
            myImageView.image = selectedImage
        }

    }

    func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
        picker.dismiss(animated: true, completion: nil)
    }
于 2017-11-02T12:42:14.820 回答
0

在Swift 4.2Xcode 10.0上有同样的问题。尽管图像选择器工作正常,但 Xcode 在控制台上显示了此错误。要摆脱这个:

  • 在 Xcode 菜单 Product > Scheme > Edit Scheme
  • 选择“运行”选项卡,然后选择“参数”
  • 在“环境变量”部分添加一个名称为 OS_ACTIVITY_MODE和值禁用的变量
于 2018-10-14T18:07:36.887 回答
0

我阅读了所有这些答案,并在此处稍作修改,无需忽略,这对我有用,感谢其他在这里回复的人。

    @objc func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

      print("########### media picked")
      picker.dismiss(animated: true, completion: nil)
      let img = (info[UIImagePickerControllerOriginalImage] as? UIImage)!
      //set img -picked image to "profileImage" UIimageView
      //use image here
       self.profileImage.image = img
       }
    }
于 2017-10-25T09:38:53.920 回答
0

Swift 5 及更高版本:

import UIKit

class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

    @IBOutlet weak var pic: UIImageView!
    @IBOutlet weak var text: UILabel!

    var chosenImage : UIImage!

    override func viewDidLoad() {
        super.viewDidLoad()
        pic.isUserInteractionEnabled = true
    }



func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
        guard let image = info[.editedImage] as? UIImage else { return }
        dismiss(animated: true)
        chosenImage = image
        **pic.image = chosenImage**

    }

    @IBAction func tap(_ sender: Any) {
        self.text.text = "Kreason"
        let imagePicker = UIImagePickerController()
        imagePicker.delegate = self
        //imagePicker.dataSource = self
        imagePicker.allowsEditing = false
        self.present(imagePicker, animated: true)

    }
}
于 2019-05-31T19:19:06.567 回答
0

单击 imageView 以从照片库加载图像并在同一 imageview 上显示预览。在迅速 4

 let imagePicker = UIImagePickerController()
        @IBOutlet weak var userImage: UIImageView! 

     override func viewDidLoad() {
                super.viewDidLoad()
                 imagePicker.delegate = self
                let tap = UITapGestureRecognizer(target: self, action: #selector(SignUpViewController.click))
                userImage.addGestureRecognizer(tap)
                userImage.isUserInteractionEnabled = true
            }

            @objc func click()
            {
                imagePicker.allowsEditing = false
                imagePicker.sourceType = .photoLibrary
                present(imagePicker, animated: true, completion: nil)
            }


            @objc func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
                if  let chosenImage = info[UIImagePickerControllerOriginalImage] as? UIImage{
                userImage.contentMode = .scaleAspectFit
                userImage.image = chosenImage
                }
                dismiss(animated: true, completion: nil)
            }

            func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
                dismiss(animated: true, completion: nil)
            }
于 2017-12-12T07:53:15.760 回答
0

使用 didFinishPickingMediaWithInfo

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
        self.dismiss(animated: true, completion: nil)
        var chosenImage = info[UIImagePickerController.InfoKey.editedImage] as! UIImage
        userProfileImage.image = chosenImage

        uploadImage(chosenImage)
}
于 2019-02-05T23:10:18.837 回答
-3

对我有用的解决方案只是进入 Product (在屏幕顶部)-> Scheme -> EditScheme -> Arguments

在环境变量中,添加值为“禁用”的 OS_ACTIVITY_MODE

希望这对其他人有用!

我会附上截图,以防我的描述看起来令人困惑在此处输入图像描述

于 2018-04-27T21:27:14.870 回答