从iphone应用程序启动照片库

时间:2010-11-25 09:21:36

标签: iphone gallery photo launch

是否可以从我的应用启动(重定向用户)iphone的原生照片库应用程序,类似于电子邮件?现在可以在4.2 sdk中使用吗?

1 个答案:

答案 0 :(得分:6)

为此,您必须创建并呈现UIImagePickerController,如下所示:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
[self presentModalViewController:imagePicker animated:YES];

如果您希望用户改用相机,可以将imagePicker.sourceType更改为imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

委托方法:- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info将为您提供info词典中的图片。