Reputation: 63
I am new to this iPhone development. Am developing a catalogue application. In that i need to give all product details with product images as tableview cell image dynamically since my images are coming from web service. I did this,
NSString* imageName = [NSString stringWithFormat:@"%@",[[stories objectAtIndex:indexPath.row]objectForKey:@"product_thumb_image"]];
cell.imageView.image.size.width==20;
cell.imageView.image.size.height==20;
cell.imageView.image = [UIImage imageNamed:imageName];
NSLog(@"imagename:%@",[[stories objectAtIndex:indexPath.row]objectForKey:@"product_thumb_image"]);
Am getting all the images in my console window and i checked that using nslog. But am not getting the images with simulator.What am doing wrong in this? Can anyone of you help me out?
Thanks in advance.
Upvotes: 0
Views: 1525
Reputation: 31016
Apple documentation contains an example of putting downloaded images into table cells. It's called LazyTableImages and would probably help with what you're trying to do.
Upvotes: 0
Reputation: 17478
Do as follows:
NSString *imageName = [NSString stringWithFormat:@"%@",currentLink];
cell.imageView.image = [UIImage imageNamed:imageName];
Upvotes: 0
Reputation: 6522
UIImage imageNamed:
takes an NSString so if you want to use a formatted string like that use NSString
's stringWithFormat
try:
cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",currentLink]];
As you are new to iPhone development I'll just expand that out to make it clearer (Ignore this if you already got what was happening there)
NSString* imageName = [NSString stringWithFormat:@"%@",currentLink];
cell.imageView.image = [UIImage imageNamed:imageName];
Upvotes: 1