I have a .plist that references paths to .png files ( key value = "maps" ). I am able to add the images to an array wi开发者_Go百科th by using this code while loading the view:
-(void)viewDidLoad {
NSString *path = [[NSBundle mainBundle] pathForResource:@"countries" ofType:@"plist"];
NSArray *countries = [NSArray arrayWithContentsOfFile:path];
NSSortDescriptor *descriptor = [[[NSSortDescriptor alloc] initWithKey:@"maps" ascending:NO] autorelease];
self.sortedCountries = [countries sortedArrayUsingDescriptors:[NSArray arrayWithObject:descriptor]];
}
I am able to add the images to TableViewCells by using this method:
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {}
What I am trying to do is add these same images to an instance of UIImageView in a new ViewController. I have the ViewController set up properly, but how can I pull the images from the array do display in a UIImageView as I did for the UITableViewCells?
when you selecting the row of table following method get call-
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UserDetailVC* userDetailVC=[[UserDetailVC alloc] initWithNibName:@"UserDetailVC" bundle:nil];
[userDetailVC autorelease];
//imp- set the image over here
NSDictionary* tempDict=[yourArray objectAtIndex:indexPath.row];
userDetailVC.selectedImageView.image=[tempDict objectForKey:@"imageName"];
[self.navigationController pushViewController:userDetailVC animated:YES];
return nil;
}
so tried this, this will definitely gone help you.
加载中,请稍侯......
精彩评论