ios UIImagePicker tutorial

14 May


#import <UIKit/UIKit.h>

@interface MyImagePickerViewController : UIViewController
    UIImagePickerController *ipc;
    IBOutlet UIImageView *bgImage;

@property (nonatomic,retain) UIImageView *bgImage;

-(IBAction) buttonClicked;



#import "MyImagePickerViewController.h"

@implementation MyImagePickerViewController

@synthesize bgImage;

-(IBAction) buttonClicked{

ipc=[[UIImagePickerController alloc]init];
ipc.delegate = self;

if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])

ipc.sourceType = UIImagePickerControllerSourceTypeCamera;
ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

[self presentModalViewController:ipc animated:YES];


-(void) imagePickerControllerDidCancel:(UIImagePickerController *)picker{

//release picker

[[picker parentViewController]dismissModalViewControllerAnimated:YES];

[picker release];

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

//set image

bgImage.image = [info objectForKey:UIImagePickerControllerOriginalImage];
//release picker

[[picker parentViewController]dismissModalViewControllerAnimated:YES];

[picker release];


- (void)dealloc
[super dealloc];

- (void)didReceiveMemoryWarning
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.

#pragma mark - View lifecycle

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
[super viewDidLoad];

- (void)viewDidUnload
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);



1 Comment

Posted by on May 14, 2012 in iphone


Tags: ,

One response to “ios UIImagePicker tutorial

  1. sms en masse

    April 5, 2014 at 9:23 pm

    Ialways used to read article in news papers but nnow as I am a usewr
    of net thus from now I am using net for posts, thanks to web.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: