i want to display image in fix size in table cell
in my iphone application images are comming from xml feed and they have variant size,how can i resize them to fix width and hight programmatically.
my cod开发者_高级运维e is in which i want to display images in cell of same width and size.my image are comming from rss fedd.
int blogEntryIndex1 = [indexPath indexAtPosition: [indexPath length] -1];
imgstring=[[blogEntries objectAtIndex: blogEntryIndex1] objectForKey: @"image"];
NSURL *url = [NSURL URLWithString:imgstring];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
cell.imageView.image=img;
please help me out if you can thanks in advance.
Hi change your code like this,
NSString *imgstring =[[blogEntries objectAtIndex: blogEntryIndex1] objectForKey: @"image"];
NSURL *url = [NSURL URLWithString:imgstring];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
UIImageView *subview = [[UIImageView alloc] initWithFrame:CGRectMake(10.0f, 10.0f,60.0f, 60.0f)];
[subview setImage:[UIImage imageNamed:img]];
[subview setContentMode:UIViewContentModeScaleToFill];
[cell.contentView addSubView:subview];
try this one. I hope it will help you.
精彩评论