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 03-29-2011, 04:11 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 2
seano55 is on a distinguished road
Default UIImageView Controlled By UITableView Choice

Hi there,
I am new to iphone dev and SDK. I am currently developing a navgation based app with multiple views just to practice and I am trying to figure out if I can change the image in the UIImageView depending on what the user chooses in the UITableView. For example say it is a flower app...the user would click on "Rose" in the table and an image of a Rose would transition onto the screen, or if they clicked on "Lily" and and image of a Lilly would show up, etc...
I would potentially need to do this for hundreds of different entries. I currently have information stored on a plist about each entry. Is there any way that I can store an image in the plist. If not what is the best way to store images? Also how would i access them in the app so that each image appeared when it was called by the user in the table view.

Thanks in advance!

Peace,
Sean
seano55 is offline   Reply With Quote
Old 03-29-2011, 04:18 PM   #2 (permalink)
Indie Developer
 
iSDK's Avatar
 
Join Date: Jul 2010
Posts: 1,346
iSDK is on a distinguished road
Send a message via AIM to iSDK
Default

This would be fully dependant on whether your images and tableviewcells have the same name:

Code:
NSString *text = [[[tableView cellForRowAtIndexPath:indexPath] textLabel]text];

imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@.png", text]];
that would go in the didSelectRow... method.

Quote:
Originally Posted by seano55 View Post
Hi there,
I am new to iphone dev and SDK. I am currently developing a navgation based app with multiple views just to practice and I am trying to figure out if I can change the image in the UIImageView depending on what the user chooses in the UITableView. For example say it is a flower app...the user would click on "Rose" in the table and an image of a Rose would transition onto the screen, or if they clicked on "Lily" and and image of a Lilly would show up, etc...
I would potentially need to do this for hundreds of different entries. I currently have information stored on a plist about each entry. Is there any way that I can store an image in the plist. If not what is the best way to store images? Also how would i access them in the app so that each image appeared when it was called by the user in the table view.

Thanks in advance!

Peace,
Sean
iSDK is offline   Reply With Quote
Old 03-30-2011, 05:10 AM   #3 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

You can just store the names of the images in the plist, then load them up with imageNamed.

You shouldn't try to get the name from the UITableViewCell, as iSDK suggests - the convention is that a table just displays data, it shouldn't be the source of the data.
harrytheshark is offline   Reply With Quote
Old 04-01-2011, 02:05 PM   #4 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 2
seano55 is on a distinguished road
Default

Quote:
Originally Posted by harrytheshark View Post
You can just store the names of the images in the plist, then load them up with imageNamed.

You shouldn't try to get the name from the UITableViewCell, as iSDK suggests - the convention is that a table just displays data, it shouldn't be the source of the data.
Thanks, I ended up the imageNamed method and it worked fine.
seano55 is offline   Reply With Quote
Reply

Bookmarks

Tags
image background, storing images, uiimageview, uitableview

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: 367
11 members and 356 guests
condor304, dansparrow, dre, ilmman, LezB44, michelle, Objective Zero, Sami Gh, shagor012, thephotographer, tinamm64
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

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