开发者

Load image from the iPhone library [duplicate]

开发者 https://www.devze.com 2023-04-03 09:57 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Load image from photo library
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Load image from photo library

How do I create a function to load an image from the iPhone library, and h开发者_开发百科ow would I be able to load it into a variable (get the URL/path of the image)?


You can use UIImagePickerController,

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

and a delegate method to get select image from the gallery,

- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
    UIImage *myImage = image;
}

Hope it gives you an idea...


Because the photo library may contain personal images, the only way to access it is via user interaction.

You will need to use the UIImagerPickerController which will display an interface allowing the user to pick an image from their Camera Roll, Photo Library or even take a picture or video using the camera.

Read the docs for the UIImagePickerController and learn how to use it.

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html

0

精彩评论

暂无评论...
验证码 换一张
取 消