我得到了这个 uiactionsheet,它在 UISplitViewController 中的 viewcontroller 中加载了 uipickerviewcontroller
这是一个UIsplitviewcontroller,这段代码在detailview上,detailview是从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
}
警告是这样的:警告:尝试呈现已经呈现的(空)
如果我使用这个: 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)
它显示并关闭?!?!