1.添加代理UIImagePickerControllerDelegate

  2.设置点击跳转事件

- (IBAction)picButton:(UIButton *)sender {

NSLog(@"我的相册");

if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]){

//a.初始化相册拾取器

UIImagePickerController *controller = [[UIImagePickerController alloc] init];

//b.设置代理

controller.delegate = self;

//c.设置资源:

/**

UIImagePickerControllerSourceTypePhotoLibrary,相册

UIImagePickerControllerSourceTypeCamera,相机

UIImagePickerControllerSourceTypeSavedPhotosAlbum,照片库

*/

controller.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

//d.随便给他一个转场动画

controller.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;

[self presentViewController:controller animated:YES completion:NULL];

}else{

UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"设备不支持访问相册,请在设置->隐私->照片中进行设置!" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];

[alert show];

}

}

  3.获取图片

#pragma mark-> imagePickerController delegate

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

{

//a.获取选择的图片

UIImage *image = info[UIImagePickerControllerOriginalImage];

self.imageView.image = image;

}

最新文章

  1. 抽象工厂模式(Abstract Factory Pattern)
  2. 【转】ORACLE定期清理INACTIVE会话
  3. Libcurl多线程crash问题(cento)
  4. ue4 模块的构建和加载
  5. Enum:Backward Digit Sums(POJ 3187)
  6. Girls: different perspectives to consider
  7. 上海洋码头(www.ymatou.com)急招技术人才(职位:互联网软件开发工程师,.NET网站架构师,Web前端开发工程师,高级测试工程师,产品经理)
  8. ubuntu启动失败the system is running in low graphics mode
  9. hdu 4652 Dice 概率DP
  10. MongoDB命令行操作
  11. 某APK中使用了动态注册BroadcastReceiver,Launcher中动态加载此APK出现java.lang.SecurityException异常的解决方法
  12. Servlet页面间对象传递的方法
  13. 【JSONKit】序列化Dictionary崩溃
  14. smarty如何处理状态值的显示
  15. poj3177(边双连通分量+缩点)
  16. CRtmpServer分析与应用
  17. CentOS7 安装Nginx+MySQL
  18. Mysql数据库使用量查询及授权
  19. nginx 系列 1 linux下安装以及配置IIS分发
  20. 【学习】数据处理基础知识(基本功能)【pandas】

热门文章

  1. linux命令chown和chmod什么区别
  2. 关于前台主键输入错误对后台hibernate方法的影响
  3. websphere安装
  4. 网络获取的XML的Pull解析
  5. SSL交互过程
  6. fpSpread1 简单用法
  7. hdu_3886_Final Kichiku “Lanlanshu”(数位DP)
  8. 励研(LY) CRC16算法
  9. HQL中左连接,右连接,内连接
  10. hihocoder网络流一·Ford-Fulkerson算法