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

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

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

  2021-03-22 我要评论
想了解IOS获取系统相册中照片的代码实例的相关内容吗,在本文为您仔细讲解IOS获取系统相册的照片的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:ios,获取系统相册,ios,获取系统相册图片,ios,获取系统相册列表,下面大家一起来学习吧。

先来看看效果图

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

#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如何获取系统相册照片的示例代码,有需要的朋友们可以直接用,对大家的开发还是很有帮助的,如果大家有疑问可以留言交流。

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们