UIImagePicker给出运行时错误

时间:2015-11-16 14:09:38

标签: ios swift uiimagepickercontroller

这是我的代码。我已经实现了UIImagePicker但是在运行时它没有显示允许在模拟器中访问图库的对话框

@IBOutlet var uploadImage: UIImageView!

@IBAction func upldImageBtn(sender: UIButton) {
    imagePicker.allowsEditing = false
    imagePicker.sourceType = .PhotoLibrary

    presentViewController(imagePicker, animated: true, completion: nil)
}

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
    if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage{
    uploadImage.contentMode = .ScaleAspectFill
    uploadImage.image = pickedImage
    uploadImage.layer.borderWidth = 0.5
    uploadImage.layer.masksToBounds = false
    uploadImage.layer.cornerRadius = uploadImage.frame.size.height/2
    uploadImage.clipsToBounds = true
    }

    dismissViewControllerAnimated(true, completion: nil)
}

1 个答案:

答案 0 :(得分:0)

尝试重置模拟器。

该选项在菜单中可用 - > iOS模拟器 - >重置内容和设置...

如果这没有帮助,请发布您看到的运行时错误的详细信息。