Warrior
Warrior

Reputation: 39374

How to access the photo from the library in iPad?

I want to access the iPad photo library and retrieve the image and display it in a image-view.

Upvotes: 2

Views: 1854

Answers (3)

gary
gary

Reputation: 4255

The iPad equivalent of an UIImagePickerController is a UIPopoverController. This YouTube video shows a basic implementation: http://www.youtube.com/watch?v=gaaLMKuPwfU. I just added a check so that only one Popover is present at a time; see if (pop.isPopoverVisible == TRUE) below. And the video shows how to connect up the button using Interface Builder. (And obviously, you'll need images on your device or simulator for this to work.) Hope it helps.

The header file:

#import <UIKit/UIKit.h>

@interface MyViewController : UIViewController <UIPopoverControllerDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate>
{    
}
- (IBAction)barBtn1:(id)sender;

@end

The implementation file:

#import "MyViewController.h"

@implementation MyViewController

- (IBAction)barBtn1:(id)sender
{
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    [imagePicker setDelegate:self];

    // If user selects button while previous pop is visible, dismiss previous pop.
    if (pop.isPopoverVisible == TRUE)
    {
        [pop dismissPopoverAnimated:YES];
    }
    UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
    [pop setDelegate:self];
    [pop presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    [imagePicker release];
}

Upvotes: 0

hotpaw2
hotpaw2

Reputation: 70673

Are you looking for help with the UIImagePickerController?

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

Upvotes: 0

Related Questions