在我下面的课程中,imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject])
没有被调用,我也不明白为什么。这是一个扩展JSQMessagesViewController
的类,不知道是否与它有关。
故事板中未添加UIImagePickerController
。我猜它是在扩展JSQMessagesViewController
时添加的?(不能告诉)
无论如何,我可以看到函数actionSheet
确实调出了imagePicker相册,我可以选择一个图像但是imagePicker函数didFinishPickingMediaWithInfo
永远不会被调用。
如何将此类指定为其委托?
Here is the complete class code(GitHub上的这个例子正在运行,但我无法让它在我的项目中运行,我缺少什么?)
class ChatViewController: JSQMessagesViewController, UIActionSheetDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
}
//DELETED THE REST OF THE CODE OF THIS CLASS TO KEEP THIS QUESTION LENGTH SHORT
func actionSheet(actionSheet: UIActionSheet, clickedButtonAtIndex buttonIndex: Int) {
NSLog("ChatViewController-> actionSheet(clickedButtonAtIndex)")
if buttonIndex != actionSheet.cancelButtonIndex {
if buttonIndex == 1 {
Camera.shouldStartCamera(self, canEdit: true, frontFacing: true)
} else if buttonIndex == 2 {
Camera.shouldStartPhotoLibrary(self, canEdit: true)
} else if buttonIndex == 3 {
Camera.shouldStartVideoLibrary(self, canEdit: true)
}
}
}
// MARK: - UIImagePickerControllerDelegate
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
//THIS FUNCTION NEVER GETS CALLED AFTER AN IMAGE IS SELECTED FROM THE PHOTO ALBUM
}
}
答案 0 :(得分:1)
Camera.shouldStartPhotoLibrary
方法可能会显示UIImagePickerController
。检查定义的位置。