美文网首页
iOS如何获取系统相册图片

iOS如何获取系统相册图片

作者: 我不白先生 | 来源:发表于2020-12-03 15:13 被阅读0次

ViewController.m

#import "ViewController.h"
@interface ViewController ()<UINavigationControllerDelegate ,UIImagePickerControllerDelegate>
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    UIImagePickerController *vc = [UIImagePickerController new];
    //有三种 照相机 文件夹 相册
   // vc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    vc.delegate = self;
    vc.allowsEditing = YES;
    [self presentViewController:vc animated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey,id> *)info{
    NSLog(@"%@",info);
    UIImage *image = info[@"UIImagePickerControllerOriginalImage"];
    UIImageView *iv = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)];
    iv.image = image;
    [self.view addSubview:iv];
    [self dismissViewControllerAnimated:YES completion:nil];
}
@end

相关文章

网友评论

      本文标题:iOS如何获取系统相册图片

      本文链接:https://www.haomeiwen.com/subject/meoziktx.html