how to add image from photo library or camera to my Ipad application?

后端 未结 3 1786
北海茫月
北海茫月 2021-01-15 13:28

I want to add images from photo library or by using camera to my ipad application. I had used same coding as iphone . But the application is crashing. I think this is not t

3条回答
  •  有刺的猬
    2021-01-15 13:50

    The answer is in your error message.

    Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'On iPad, UIImagePickerController must be presented via UIPopoverController'
    

    On an iPad, you can't just use the iPhone method of selecting an image. You need to use a UIPopoverController, you can pass it your UIImagePickerController with:

    UIPopoverController* popover = [[UIPopoverController alloc] initWithContentViewController: imagePicker];

    Then implement the UIPopoverControllerDelegate protocol in your class.

    You can find an example of this here.

提交回复
热议问题