简体   繁体   English

从iphone应用程序启动照片库

[英]launch photo gallery from iphone App

Is it possible to launch (redirect the user to) the native photo gallery application of iphone from my app, similar to emails? 是否可以从我的应用程序启动(重定向用户)iphone的本机照片库应用程序,类似于电子邮件? Is this now possible in 4.2 sdk? 现在可以在4.2 sdk中使用吗?

For this, you have to create and present a UIImagePickerController like this: 为此,您必须创建并呈现如下的UIImagePickerController

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

You can change imagePicker.sourceType to imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; 您可以将imagePicker.sourceType更改为imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; if you want the user to use the camera instead. 如果您希望用户改为使用相机。

The delegate method: - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info will give you the image in the info dictionary. 委托方法: - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info将为您提供info字典中的图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM