我想解雇这个观点。我已经能够在按钮上添加一个目标,该按钮会显示一个操作表,让用户从库中选择他们的照片。然而,在我"选择"视图不被解雇的图像。
以下是didFinishPickingMediaWithInfo
:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
var chosenImage = UIImage()
chosenImage = info[UIImagePickerControllerOriginalImage] as! UIImage
profileImageView.image = chosenImage
// This doesn't work...
self.window?.rootViewController?.dismiss(animated: true, completion: nil)
print("Should dismiss")
}
我像这样提出alertController:
self.window?.rootViewController?.present(alertController, animated: true, completion: nil)
答案 0 :(得分:0)
您正在正确呈现和解除UIImagePickerController。问题必须在于如何呈现它以及当您关闭它时哪个视图控制器位于堆栈顶部。尝试在包含委托的当前ViewController上展示它。