【发布时间】:2016-11-29 11:59:31
【问题描述】:
我在这里寻求帮助!
我在 swift 中有一个 ActionController,我试图从创建的其中一个动作中呈现一个 UIImagePickerController,但是当我运行它时,它向我显示了这个警告:尝试在 <...> 上呈现,它已经呈现(null),并且它没有呈现任何东西。
这是我的代码:
let actionController = TweetbotActionController()
actionController.addAction(Action("Photo Library", style: .Default , handler: { action in
let picker = UIImagePickerController()
picker.sourceType = .PhotoLibrary
picker.allowsEditing = false
picker.delegate = self
self.presentViewController(picker, animated: true, completion: nil)
}))
actionController.addAction(Action("Take Photo", style: .Default, handler: {action in
NSLog("Take Photo Pressed")
}))
actionController.addSection(Section())
actionController.addAction(Action("Cancel", style: .Cancel, handler:nil))
presentViewController(actionController, animated: true, completion:nil)
非常感谢!!!
【问题讨论】:
-
我试过这个: if self.presentedViewController == nil { self.presentViewController(picker, animated: true, completion: nil) } 但它消除了警告但不显示pickerController。跨度>
-
您在关闭 ActionController 之前呈现 ImagePicker。尝试关闭“actionController”,然后在完成处理程序中打开 ImagePicket。
-
你的意思是“关闭actionController”使用这个:dispatch_async(dispatch_get_main_queue() ?
-
没有类似的东西 "dismissViewControllerAnimated(true) { // 在此处打开 ImagePicker } "
-
知道了!!!它完美地工作。感谢您的帮助
标签: swift