码迷,mamicode.com
首页 > 其他好文 > 详细

调用系统的相册

时间:2015-06-30 21:55:00      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

第一步遵守协议,UIImagePickerControllerDelegate,UINavigationControllerDelegate

第二步:创建picker对象

    UIImagePickerController * picker = [[UIImagePickerController alloc]init];
第三步 :打开的模式三种

    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    UIImagePickerControllerSourceTypePhotoLibrary,
    UIImagePickerControllerSourceTypeCamera,
    UIImagePickerControllerSourceTypeSavedPhotosAlbum

第四步:设置代理

    picker.delegate = self;
第五步:进入相册

    [self presentViewController:picker animated:YES completion:nil];
选中相册中某一种照片的协议方法为

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
        //获取选中的图片
    UIImage * selectImage = [info objectForKey:UIImagePickerControllerOriginalImage];
    self.imageView.image = selectImage;
    //将picker隐藏
    [picker dismissViewControllerAnimated:YES completion:nil];
}

 

调用系统的相册

标签:

原文地址:http://www.cnblogs.com/huoxingdeguoguo/p/4611492.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!