UIImagePickerController takePicture not responding

左心房为你撑大大i 提交于 2019-12-11 05:57:03

问题


I init the UIImagePickerController:

    imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.delegate = self;
    imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceFront;

and then use this method [imagePicker takePicture];

and I not get any call to the delegate method:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

Any idea why?


回答1:


You don't mention if you're actually presenting the image picker controller to the user by calling -presentViewController:animated:completion: (or the older presentViewController:animated:).

Apple's docs don't explicitly say so, but I'm pretty sure the image picker controller needs to be shown on screen in order for -takePicture to work, otherwise you would be able to take pictures without the user knowing.




回答2:


To use an image picker controller, you must provide a delegate that conforms to the UIImagePickerControllerDelegate protocol.

if it does, verify that the device is capable of picking content from the desired source. Do this calling the isSourceTypeAvailable: class method, providing a constant from the “UIImagePickerControllerSourceType” enum.

Also check 'self' hasn't been released.



来源:https://stackoverflow.com/questions/8068436/uiimagepickercontroller-takepicture-not-responding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!