首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

获取系统相本中图片的方法

2012-08-25 
获取系统相册中图片的方法原文地址:获取系统相册中图片的方法http://www.aisidachina.com/forum/viewthrea

获取系统相册中图片的方法
原文地址:获取系统相册中图片的方法
http://www.aisidachina.com/forum/viewthread.php?tid=244

定义一个按钮连接以下方法:

- (IBAction)selectExistingPicture {    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])         {        UIImagePickerController *picker = [[UIImagePickerController alloc] init];        picker.delegate = self;        picker.allowsImageEditing = YES;        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;        [self presentModalViewController:picker animated:YES];        [picker release];    }    else {        UIAlertView *alert = [[UIAlertView alloc]                               initWithTitle:@"访问图片库错误"                               message:@""                               delegate:nil                               cancelButtonTitle:@"OK!"                               otherButtonTitles:nil];        [alert show];        [alert release];    }}


再调用以下委托:
#pragma mark UIImagePickerControllerDelegate- (void)imagePickerController:(UIImagePickerController *)picker         didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {        imageView.image = image;        //imageView为自己定义的UIImageView                    [picker dismissModalViewControllerAnimated:YES];    }

热点排行