UIImagePickerController 使用示例
从图片库获取数据
- (IBAction)doPhotoAlbumBtn:(UIButton *)sender {
UIImagePickerController* ipController = [[UIImagePickerController alloc] init];
[self presentViewController:ipController animated:YES completion:nil];
[ipController setDelegate:self];
}
从相机获取数据
UIImagePickerController* ipController = [[UIImagePickerController alloc] init];
if ([[[UIDevice currentDevice] model] rangeOfString:@"Sim"].location == NSNotFound) {
[ipController setSourceType:UIImagePickerControllerSourceTypeCamera];
[ipController setDelegate:self];
[self presentViewController:ipController animated:YES completion:nil];
}
实现下面的代理方法
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { NSLog(@"%@", [info objectForKey:UIImagePickerControllerOriginalImage]); UIImage* img = [info objectForKey:UIImagePickerControllerOriginalImage]; // TODO [self dismissViewControllerAnimated:NO completion:nil]; // TODO }
posted on 2014-01-23 15:16 MoreNotepad++ 阅读(139) 评论(0) 收藏 举报
浙公网安备 33010602011771号