如何在我的应用程序中实现"选择现有照片",如默认的iPhone电话簿?

Cha*_*har 10 iphone objective-c capture uiimageview

我想开发一个应用程序,其功能与iphone电话簿捕获图像和选择iamge相同,

我该怎么做才能做到这一点

我为UIActionSheet制作了一个UIImageView和一个按钮,

现在我想在我的应用程序中执行"拍照"和"选择现有照片"选项

帮助我,我很感激

提前致谢 ....

Rob*_*bin 10

嘿@Veer你需要使用UIImagePickerController

查看文档 http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html 并查看此链接

http://iphone.zcentric.com/2008/08/28/using-a-uiimagepickercontroller/

它有相同的示例.

编辑您可以使用这些方法获取UIImageView对象中的图像

- (void)selectPhotos
{
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    picker.delegate = self;
    [self presentModalViewController:picker animated:YES];
    [picker release];
}

- (void)imagePickerController:(UIImagePickerController *)picker
        didFinishPickingImage:(UIImage *)image
                  editingInfo:(NSDictionary *)editingInfo
{
    imageView.image = image;
    [[picker parentViewController] dismissModalViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud)