从iPhone应用程序中启动照片库

3

我能否像电子邮件一样从我的应用程序中启动(将用户重定向到)iPhone的本地照片库应用程序?是否在4.2 sdk中实现了此功能?


我不知道是哪个例子,但你可以在自己的应用程序中显示照片应用中的照片。请查看苹果的示例代码。 - ingh.am
1个回答

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 字典中提供图像。


谢谢回复。我想启动本机iPhone应用程序照片库,而不仅仅是能够从照片库中选择图像,我想知道是否可能使用最新的SDK实现。 - irpalo
我不知道是否有任何API可以启动照片应用程序。以下是一些您可以使用自定义URL方案启动的应用程序列表:http://applookup.com/2010/09/iphone-apps-with-special-url-shortcuts/ - Chintan Patel

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接