Reputation: 641
i my iphone applicaion image in right of table cell are extracted from xml feed. Know i want to display them in fix size can any body help me out. bellow is the code
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;
cell.textLabel.text=headline;
Thanks in advance i will be waiting
Upvotes: 0
Views: 872
Reputation: 719
Set the content mode of your UIImageView to UIViewContentModeScaleAspectFit or to UIViewContentModeCenter if your images do not require any scaling.
[yourImageView setContentMode:UIViewContentModeScaleAspectFit];
Take a look at the examples in the API. There is a better way to load images for table view cells. http://developer.apple.com/iphone/library/samplecode/LazyTableImages
And for a better understanding of the anatomy of table view cells read this: http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html
Upvotes: 1