IOS获取系统相册中照片的示例代码_IOS开发教程-查字典教程网
IOS获取系统相册中照片的示例代码
IOS获取系统相册中照片的示例代码
发布时间:2016-12-28 来源:查字典编辑
摘要:先来看看效果图下面话不多少,我们直接上代码:#import"ViewController.h"@interfaceViewControlle...

先来看看效果图

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

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

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新IOS开发学习
    热门IOS开发学习
    编程开发子分类