呈現的UIImagePickerController有我的故事板的該部分:從模態視圖控制器
所以我想從UserProfileController存在:UIViewController的 「Мойпрофиль」,這是模態,(關於圖像的頂部)UIImageViewController。
我的代碼:
extension UserProfileController: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
@IBAction func imagePressed(_ sender: Any) {
let imagePickerController = UIImagePickerController()
imagePickerController.delegate = self
self.present(imagePickerController, animated: true, completion: nil)
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
guard let image = info[UIImagePickerControllerOriginalImage] as? UIImage else {
return
}
picker.dismiss(animated: true, completion: nil)
userProfileImageView.image = image
}
}
好,imagePickerController呈現,但我選擇圖片後,我已經被解僱兩個控制器(imagePickerController和家長 - UserProfileControler)。
我在做什麼錯?謝謝
P.S.可能是問題是我顯示「SideMenuNavigationController」爲模態? (SideMenu框架文檔中,以便決定)
可以嘗試把@IBAction擴展之外? – Adolfo
已經做到了,IBAction與imagePicker相同:didFinish方法在聲明類體 – zzheads