Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        4年前关闭。
                                                                                            
                
        
在下面的课程中,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

}



}

最佳答案

Camera.shouldStartPhotoLibrary方法可能显示UIImagePickerController。检查在哪里定义。

关于ios - imagePickerController didFinishPickingMediaWithInfo没有在图像选择上被调用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31232891/

10-13 03:57