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-21-2011, 11:27 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 67
gbenna is on a distinguished road
Default load image from plist to selected cell xib

I am working on an app that has a grouped table view. Each cell has an image, a title text, and a detail text that is stored in a plist. the plist also has the headers for the group headers and a view controller associated with that cell. I call the specified view controller to load the associated xib file for each cell selected. However most of the xibs have the same format ( an image, some text, and a play button to play some audio. there is also a button to flip the view. In this case I feel it would be wise to call on the same view controller to load the same nib but populate it with different variables associated with the cell selected. I have the variables included within the plist. but I am stymied as to how to write the code to have them displayed when the corresponding cell is selected. I have found an example that seems to do what I want by calling on the delegate however there are a few differences and I can't seem to get it to work. If anyone can give me some pointers, point me in the direction of a video tutorial of something I would really appreciate it.


here is the code I used to call the view controller to load the nib file and the code to load the image and text into the xib. from the plist depending on the cell selected.

- (void)tableViewUITableView *)tableView didSelectRowAtIndexPathNSIndexPath *)indexPath {
const NSDictionary *const row = [self rowForIndexPath:indexPath];

TableViewPushAppDelegate *appDelegate = (TableViewPushAppDelegate *)[[UIApplication sharedApplication]delegate];
appDelegate.myImage= [[NSString alloc]initWithFormat:@"%@",[[tableDataSm objectAtIndex:indexPath.row]objectForKey:@"picture"]];

NSLog(@"%@", appDelegate.myImage);

appDelegate.textView = [[NSString alloc]initWithFormat:@"%@",[[tableDataSm objectAtIndex:indexPath.row]objectForKey:@"description"]];

NSString *wantedClassName = [row objectForKey:@"controller"];

UIViewController *const vc = [[NSClassFromString (wantedClassName) alloc] init];
NSLog(@"controller is -%@-", wantedClassName);
[self.navigationController pushViewController:vc animated:YES];

[vc release];

this is put in the view controller

@synthesize textViewTwo;
@synthesize imageOne;

-(id) init{
if((self = [super initWithNibName:@"Location One" bundle:nil])){

}
return self;
}


- (void)viewDidLoad {
NSLog(@"InView did load");

[super viewDidLoad];

TableViewPushAppDelegate *appDelegate = (TableViewPushAppDelegate *)[[UIApplication sharedApplication]delegate];


textViewTwo.text = [[NSString alloc] initWithFormat:@"%@", appDelegate.textView];

NSString *path = [[NSString alloc]initWithFormat:@"%@",appDelegate.myImage];
UIImage *img = [UIImage imageNamedath];
[imageOne setImage:img];
}


Thanks,

Gary

Last edited by gbenna; 07-22-2011 at 02:43 PM. Reason: add more information
gbenna is offline   Reply With Quote
Reply

Bookmarks

Tags
cells, images, plist, tableview

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: 403
17 members and 386 guests
7twenty7, blasterbr, buggen, chiataytuday, Clouds, dre, EvilElf, fiftysixty, HemiMG, jeroenkeij, jimmyon122, jonathandeknudt, LEARN2MAKE, n00b, nyoe, pungs, UMAD
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,668
Threads: 94,121
Posts: 402,901
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jonathandeknudt
Powered by vBadvanced CMPS v3.1.0

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