标签:
第一步遵守协议,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