繁体   English   中英

如何确定图像是从库中还是从相机中获取的

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM