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 04-16-2010, 02:09 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 12
Unicyclist is on a distinguished road
Default UIImageView does not load UIImage from Camera

Hi!

I defined the following property in my subclass of UIViewController called ExperimentViewController:

Code:
@property (nonatomic, retain) UIImage *store;
which i used to hold the camera image from the iphone camera with

Code:
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *) info {
	store = [info objectForKey:UIImagePickerControllerEditedImage];
	[picker dismissModalViewControllerAnimated:YES];
	
}
The problem comes about when I try to set UIImageView *imageView to store in a subClass of ExperimentViewController with in the viewDidLoad of the subClass

Code:
imageView.image = store;
The image does not come out at all. However, using the nib to set imageView to a png in my resources works out fine.

Any help would be much appreciated.

Thanks in advance!
Unicyclist is offline   Reply With Quote
Old 04-16-2010, 02:55 AM   #2 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 1
huaren is on a distinguished road
Default

i want to know when ececuting this line:
imageView.image = store;

whether is the "store" nil or not?
huaren is offline   Reply With Quote
Old 04-16-2010, 02:59 AM   #3 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 12
Unicyclist is on a distinguished road
Default

Quote:
Originally Posted by huaren View Post
i want to know when ececuting this line:
imageView.image = store;

whether is the "store" nil or not?
Hi huaren!

Thanks for the quick reply.
My apologies, I'm pretty new to iPhone programming. How do I check if store is nil?

I noticed that when I use the code

Code:
imageView.image = [UIImage imageNamed:"something.png"];
where "something.png" is a png in my resources folder, the image loads fine. However, this

Code:
imageView.image = [UIImage imageNamed:store];
does not work.
Unicyclist is offline   Reply With Quote
Old 07-05-2010, 07:46 PM   #4 (permalink)
Registered Member
 
twild's Avatar
 
Join Date: Apr 2009
Posts: 107
twild is on a distinguished road
Default

Quote:
Originally Posted by Unicyclist View Post
Hi huaren!

Thanks for the quick reply.
My apologies, I'm pretty new to iPhone programming. How do I check if store is nil?

I noticed that when I use the code

Code:
imageView.image = [UIImage imageNamed:"something.png"];
where "something.png" is a png in my resources folder, the image loads fine. However, this

Code:
imageView.image = [UIImage imageNamed:store];
does not work.
I am having the same exact problem. Did you ever figure this out?
twild is offline   Reply With Quote
Old 07-06-2010, 12:41 AM   #5 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 51
rahulvyas is on a distinguished road
Default

This will work because [UIImage imageNamed:] method return a UIIMage object
imageView.image = [UIImage imageNamed:"something.png"];

if store is a UIImage variable and it is assigned in imagePickerController's delegate method then the code should be like this imageView.image = store;

this will not work.
imageView.image = [UIImage imageNamed:store];
rahulvyas is offline   Reply With Quote
Old 07-06-2010, 07:40 AM   #6 (permalink)
Registered Member
 
twild's Avatar
 
Join Date: Apr 2009
Posts: 107
twild is on a distinguished road
Default

I quoted the wrong post, I was referring to the original post. Here is my code:

Note: this works when selecting an image from the camera roll, but not for a new picture taken with the camera. "image" is not null in either case.

Code:
#pragma mark -
#pragma mark UIImagePickerControllerDelegate
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
	
	UIImage *image = [info valueForKey:@"UIImagePickerControllerEditedImage"];
	
	// Display our image 
		_imageView0.image = image;
	
	[self dismissModalViewControllerAnimated:YES];
	
}
twild is offline   Reply With Quote
Old 07-06-2010, 10:05 AM   #7 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Try this:
Code:
 UIImage* img = (UIImage*)[info objectForKey:UIImagePickerControllerEditedImage];
 if( !img) img = (UIImage*)[info objectForKey:UIImagePickerControllerOriginalImage];

imageView.image = img;
smithdale87 is offline   Reply With Quote
Old 07-06-2010, 03:02 PM   #8 (permalink)
Registered Member
 
twild's Avatar
 
Join Date: Apr 2009
Posts: 107
twild is on a distinguished road
Default

Quote:
Originally Posted by smithdale87 View Post
Try this:
Code:
 UIImage* img = (UIImage*)[info objectForKey:UIImagePickerControllerEditedImage];
 if( !img) img = (UIImage*)[info objectForKey:UIImagePickerControllerOriginalImage];

imageView.image = img;
I will try that when I get home. I have tried using both Edited and Original, but not checking for it and assigning.
twild is offline   Reply With Quote
Old 07-06-2010, 06:14 PM   #9 (permalink)
Registered Member
 
twild's Avatar
 
Join Date: Apr 2009
Posts: 107
twild is on a distinguished road
Default

Quote:
Originally Posted by smithdale87 View Post
Try this:
Code:
 UIImage* img = (UIImage*)[info objectForKey:UIImagePickerControllerEditedImage];
 if( !img) img = (UIImage*)[info objectForKey:UIImagePickerControllerOriginalImage];

imageView.image = img;
That worked! Thanks man!
twild is offline   Reply With Quote
Reply

Bookmarks

Tags
camera, iphone, uiimage, uiimageview

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: 317
16 members and 301 guests
chemistry, Domele, Duncan C, Fstuff, givensur, heshiming, HowEver, iAppDeveloper, iphonedevshani, jbro, JoeRCruso, kapps11, newDev, SLIC, stanny, WheyLabs
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,648
Threads: 94,112
Posts: 402,874
Top Poster: BrianSlick (7,990)
Welcome to our newest member, brandon6031
Powered by vBadvanced CMPS v3.1.0

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