[英]how to detect if image from photo library was taken by iPhone camera or imported
[英]How to determine whether an image was taken from the library or from the camera
我想通过if语句检查是否从相机胶卷中拾取图像或由内置相机拍摄图像。 如何通过if语句执行此操作? 谢谢你的帮助!
码:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
toolbar.hidden = NO;
}
if (picker.sourceType == UIImagePickerControllerSourceTypePhotoLibrary) {
toolbar.hidden = NO;
}
if (picker.sourceType == UIImagePickerControllerSourceTypeSavedPhotosAlbum) {
toolbar.hidden = NO;
}
else{
toolbar.hidden = YES;
}
imgView.image = [info objectForKey:@"UIImagePickerControllerEditedImage"];
[self dismissViewControllerAnimated:YES completion:nil];
}
只需检查sourceType
:
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
//image taken with camera
}
else{
//image taken from camera roll
}
在imagePickerController:didFinishPickingMediaWithInfo:
方法中执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.