0

Currently I have a view with an ImageViewer and 2 buttons (Browse & Upload). I'm currently searching for methods to display the iPhone photo album once the button is pressed.

I've looked at this example here but I assume this one is the method you call when you want to upload the photo into the server.

Objective C: How to upload image and text using HTTP POST?

I'd like to duplicate the functionality of a web upload form. 1. Click button to browse folders. 2. Choose photo and display in a container. 3. Click Upload to upload photo into the server.

**Update: Found some nice tutorials that helped me start with my iPhone app photo upload form.

Using UIImagePickerController

http://iosdevelopertips.com/camera/camera-application-to-take-pictures-and-save-images-to-photo-album.html

http://trailsinthesand.com/picking-images-with-the-iphone-sdk-uiimagepickercontroller/

Adding images to iPhone Simulator

Cœur
  • 37,241
  • 25
  • 195
  • 267
martti d
  • 2,552
  • 2
  • 17
  • 20

2 Answers2

0

for getting images from iPhone library you have to use UIImagePickerController.

m_imagePickerController = [[UIImagePickerController alloc] init];
m_imagePickerController.delegate = self;
m_imagePickerController.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;

hope this will help you

0

You will have to use UIImagePickerController class
Here is the class reference for UIImagePickerController

Initialize the picker controller in your button event handler method.
Then set the UIImagePickerControllerDelegate to your current viewController
Here is the class reference for UIImagePickerControllerDelegate

picker.delegate = self;

Set the UIImagePickerControllerSourceType of picker to UIImagePickerControllerSourceTypePhotoLibrary

picker.UIImagePickerControllerSourceType = UIImagePickerControllerSourceTypePhotoLibrary

Then present the pickerViewController (if your target device is an iPad, present the imagePickerView in a popOver control)
Once user selects an image picker controller will automatically call its delegate method

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

You can get the selected image by accessing the value for UIImagePickerControllerOriginalImage from the NSDictionary *info

Then you can use the image for uploading to server as mentioned in the post link

These are some tutorials for UIImagePickerController Tutorial one
Tutorial two
Tutorial three

Community
  • 1
  • 1
Krrish
  • 2,256
  • 18
  • 21
  • i'm seeing only a blank view with 2 blue horizontal bars on top. `UIImagePickerController *imgP = [[UIImagePickerController alloc] init]; imgP.delegate = self; imgP.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; [self.view addSubview:imgP.view]; [imgP release];` – martti d Jan 19 '12 at 11:23
  • i'm adding it programmatically in a uiviewcontroller at loadView – martti d Jan 19 '12 at 11:31
  • ok fixed it hehe, i didnt need to create a new view for it. just called `[self presentModalViewController:picker animated:YES];` instead. :) – martti d Jan 19 '12 at 11:55
  • Good to here that, I had mentioned that you have to present a pickerView ([self presentModelView...) – Krrish Jan 19 '12 at 12:00