I need to laod a image from NSMutableArray
which is loaded from service url.I can retrieve the image tag from XML response.Now I want that image in a UITableViewCell
My array looks like this :
(
{
Image="46b6daca-3.png";
}
{
Image="9251bfe5-d.jpg";
}
)
How can I load each image in a seperate UITableViewCell
?
For creating a UILabel I knew it is like this :
NSMutableDictionary *d = (NSMutableDictionary *) [arr objectAtIndex:indexPath.row];
UILabel *line1=[[UILabel alloc]initWithFrame:CGRectMake(10, 68, 320,10)];
line1 .font=[UIFont fontWithName:@"arial" size:12];
[line1 setTextAlignment:UITextAlignmentLeft];
[line1 setText:[d valueForKey:@"Name"]];
line1.tag=113;
[cell addSubview:line1 ];
[line1 release];
How can I do it for UIImage?
UIImageView *img = [[UIImageView alloc]initWithImage:[ d objectForKey:@"Image"]];
[cell.contentView addSubView:img];
Use the following code for setting the image:
UIImage *img = [[UIImage imageNamed:[d objectForKey:@"Image"];
cell.imageView.image = img;
Here d is your NSMutableDictionary
if you have images in your array then use direct array value as a image like bellow..
UIImageView *img = [[UIImageView alloc]initWithImage:[[arrData valueForKey:@"Image"] objectAtIndex:indexPath.row];
img.frame = SetFrameHere;//
[cell.contentView addSubView:img];
or also add as a cell imageview like bellow..
cell.imageView.image = (UIImage *)[[arrData valueForKey:@"Image"] objectAtIndex:indexPath.row];
as per you code.. try this.
NSMutableDictionary *d = (NSMutableDictionary *) [arr objectAtIndex:indexPath.row];
UIImageView *img = [[UIImageView alloc]initWithImage:[ d objectForKey:@"Image"]];
img,frame = CGRectMake("Set frame")]
[cell.contentView addSubView:img];
[img release];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.