IOS获取系统相册中照片的示例代码

时间:2021-05-20

先来看看效果图

下面话不多少,我们直接上代码:

#import "ViewController.h"@interface ViewController ()<UINavigationControllerDelegate,UIImagePickerControllerDelegate>@property (weak, nonatomic) IBOutlet UIImageView *IconView;@end@implementation ViewController- (IBAction)chooseImage { //弹出系统相册 UIImagePickerController *pickVC = [[UIImagePickerController alloc] init]; //设置照片来源 pickVC.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; pickVC.delegate = self; [self presentViewController:pickVC animated:YES completion:nil];}#pragma mark - UIImagePickerControllerDelegate-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{ UIImage *photo = info[UIImagePickerControllerOriginalImage]; UIImageView *imageV = [[UIImageView alloc] init]; imageV.frame = self.IconView.frame; imageV.image = photo; imageV.userInteractionEnabled = YES; [self.view addSubview:imageV]; [self dismissViewControllerAnimated:YES completion:nil];}@end

总结

以上就是IOS如何获取系统相册照片的示例代码,有需要的朋友们可以直接用,对大家的开发还是很有帮助的,如果大家有疑问可以留言交流。

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章