UISplitViewControllerにあるviewcontrollerにuipickerviewcontrollerをロードするこのuiactionsheetを取得しました
これは UIsplitviewcontroller です。このコードは詳細ビューにあり、詳細ビューは masterview から呼び出されます。
ただし、「クリック」してロードしようとすると、警告が表示され、それ以上進みません
func actionSheet(actionSheet: UIActionSheet!, clickedButtonAtIndex buttonIndex: Int){
var imagePicker = UIImagePickerController()
imagePicker.delegate = self
switch buttonIndex{
case 0:
imagePicker.sourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum
imagePicker.allowsEditing = true
imagePicker.delegate = self
NSLog("Vælg fra Biblioteket");
break;
case 1:
imagePicker.sourceType = UIImagePickerControllerSourceType.Camera
imagePicker.allowsEditing = true
imagePicker.delegate = self
NSLog("Vælg Kamera");
break;
default:
NSLog("Default");
break;
}
self.presentViewController(imagePicker, animated: true, completion: nil) // this is the problem
}
警告は次のとおりです: 警告: Attempt to present on which is already presenting (null)
これを使用するとどうなりますか: self.showDeatilViewController(imagePicker, true) 表示されますが、まったく却下できません
これが私がそれが却下されると思った方法です
func imagePickerControllerDidCancel(picker: UIImagePickerController) {
picker.dismissViewControllerAnimated(true, completion: nil)
}
このコードをviewDidLoadで実行すると、動作します
var imagePickerController = UIImagePickerController()
imagePickerController.delegate = self
imagePickerController.sourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum
imagePickerController.allowsEditing = true
self.presentViewController(imagePickerController, animated: true, completion: { imageP in
})
私がこれを書くと、私はそれを理解しました:
self.presentedViewController?.presentViewController(imagePicker, animated: true, completion: nil)
表示して閉じる?!?!