问题描述
我有一个视图控制器,需要能够从相册和相机中选择图片.我只能有一个 didFinishPickingMediaWithInfo 委托方法,虽然我可以判断它是一个图像,但我似乎无法判断它是来自相册还是来自相机(我需要先将它保存在相册中).信息中有什么东西可以帮助我区分这两者吗?
I have a view controller that needs to be able to choose a picture from the photo album and also from the camera. I can only have 1 delegate method for didFinishPickingMediaWithInfo and while I can tell if it's an image, I can't seem to tell if it's from the album or from the camera (and I need to save it in the album first). Is there anything in the info that can help me distinguish from the two?
谢谢...
推荐答案
因为UIImagePickerController
是传递给方法的,所以你要做的就是:
Because the UIImagePickerController
is passed to the method, all you have to do is:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
if ([picker sourceType] == UIImagePickerControllerSourceTypeCamera) {
// Do something with an image from the camera
} else {
// Do something with an image from another source
}
}
这篇关于如何判断 didFinishPickingMediaWithInfo 返回的图像是来自相机还是相册?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!