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调出

   本文转自老Zhan博客园博客,原文链接:http://www.cnblogs.com/mybkn/archive/2012/06/02/2532042.html,如需转载请自行联系原作者
相关文章
|
iOS开发
Mobile - iPhone 的相册照片分享没有微信选项?
Mobile - iPhone 的相册照片分享没有微信选项?
252 0