Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-07-2010, 05:38 AM   #1 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 77
Balillas is on a distinguished road
Default Problem with UIImagePickerControllerDelegate

Hello,

I want to take a photo or select from the photo album in my app, and then save it. Actually for me very hard task...

The problem is that I created a class for the ImagePickerDelegate, looks like follow:

#import <Foundation/Foundation.h>


@interface MyImagePickerDelegate : NSObject <UINavigationControllerDelegate, UIImagePickerControllerDelegate >{
UIImage * selectedImage;
}

@property (nonatomic, retain) UIImage * selectedImage;

@end

and the implementation is:

#import "MyImagePickerDelegate.h"

@implementation MyImagePickerDelegate

@synthesize selectedImage;

- (void) imagePickerControllerDidCancel: (UIImagePickerController *) picker {
[picker.parentViewController dismissModalViewControllerAnimated: YES];
[picker release];
}

- (void)imagePickerControllerUIImagePickerControll er *) picker didFinishPickingMediaWithInfoNSDictionary *) info {
self.selectedImage = (UIImage*)[info objectForKey:UIImagePickerControllerOriginalImage];
//[[NSNotificationCenter defaultCenter] postNotificationName:@"ImagePicked" object:nil];
[picker.parentViewController dismissModalViewControllerAnimated:YES];
[picker release];
[[NSNotificationCenter defaultCenter] postNotificationName:@"ImagePicked" object:nil];
}

- (void) dealloc {
[selectedImage release];
[super dealloc];
}

@end

It's looks OK...

I have a main window with a UITableView and depending of the row selection I call the function that follows:

- (void) selectPicture{
UIImagePickerController * pickCont = [[UIImagePickerController alloc] init];
pickCont.delegate = imgPickerDelegate;
pickCont.allowsImageEditing = YES;
pickCont.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewControllerickCont animated:YES];
NSLog(@"heynow");
if(self.imgPickerDelegate.selectedImage != nil){
//[self changeImage];
}
}

All works fine, the photo albums opens and allow me to select a picture from my album but...

I put a breakpoint in function didFinishPickingMediaWithInfo in myImagePickerDelegate but the code execution never stop there! And there is where I want to mange what to do with the image.

I hope you can help me!

Sorry with me english!

Last edited by Balillas; 07-07-2010 at 06:05 AM.
Balillas is offline   Reply With Quote
Old 07-07-2010, 07:05 AM   #2 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 100
mobin_shaikh is on a distinguished road
Default

I think u use like this,

- (void)imagePickerControllerUIImagePickerControll er *)picker didFinishPickingImageUIImage *)image editingInfoNSDictionary *)editingInfo
{
//Dismiss & hide image Picker after image taken successfully
[picker dismissModalViewControllerAnimated:YES];
imagePickerController.view.hidden = YES;
}


In above function ur picked image in image object, use that....
Ithink it ll helps u
mobin_shaikh is offline   Reply With Quote
Old 07-07-2010, 08:48 AM   #3 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 77
Balillas is on a distinguished road
Default

I'm sorry but that doesn't work...

I'm getting crazy! I don't know what's the problem.

Can someone show me with a example how to do my propose?

Thanks
Balillas is offline   Reply With Quote
Old 07-07-2010, 08:54 AM   #4 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 77
Balillas is on a distinguished road
Default

From iPhone OS Reference Library:

– imagePickerController:didFinishPickingImage:editin gInfo: Deprecated in iPhone OS 3.0

We need to use - (void)imagePickerControllerUIImagePickerControll er *)picker didFinishPickingMediaWithInfoNSDictionary *)info

The problem was that when I execute the code never enter inside this function.
Balillas is offline   Reply With Quote
Old 07-07-2010, 09:23 AM   #5 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 100
mobin_shaikh is on a distinguished road
Default

Hi,

instead of this,
pickCont.delegate = imgPickerDelegate;

try this,
pickCont.delegate = self;
mobin_shaikh is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 338
9 members and 329 guests
bignoggins, Chickenrig, firecall, givensur, iNet, michaelhansen, Objective Zero, PlutoPrime, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,893
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:32 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0