iphone:使用UIImagePickerController从IPhone照片库或照相机获取图像

from: 使用UIImagePickerController从IPhone照片库或照相机获取图像

使用UIimagePickerController选取照片库操作十分简单:

在对应响应中

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

picker.delegate = self;  //控制器当然要遵循响应的delegate协议

picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; //指定picker的资源,有三种

                                                                                                   //enum { UIImagePickerControllerSourceTypePhotoLibrary,

                                   //      UIImagePickerControllerSourceTypeCamera,

                                   //     UIImagePickerControllerSourceTypeSavedPhotosAlbum }

    [selfpresentModalViewController:picker animated:YES];  //显示picker view

 

在delegate方法中:

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

  //info: A dictionary containing the original image and the edited image, if an image was picked; or a filesystem URL for the movie, if a movie was picked

    [picker dismissModalViewControllerAnimated:YES];  //让其消失

  imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

}

 

NSString *const UIImagePickerControllerMediaType;
NSString *const UIImagePickerControllerOriginalImage;
NSString *const UIImagePickerControllerEditedImage;
NSString *const UIImagePickerControllerCropRect;
NSString *const UIImagePickerControllerMediaURL;
NSString *const UIImagePickerControllerReferenceURL;
NSString *const UIImagePickerControllerMediaMetadata;

RootViewController - tableView:cellForRowAtIndexPath - Load image from assetsLibrary

Using AssetsLibrary Framework loading images too slow

 

补充:ipad的不能调出UIImagePickerController,需要通过PopOver调出

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值