I have a tableview which displays an image that is obtained from a server (via URL)
[cell.imageView setImageWithURL:[NSURL URLWithString:avatar_url]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
However, I am开发者_如何学C faced with the problem of inconsistent sizing of the image displayed in my cell. (see screenshots below):
1) How can I fix the size of the images retrieved?
2) How can I fix the cell.imageView's frame's size? Doing the following does not seem to work (cell.imageView.frame = CGRectMake(5,5,32,32).
You need to set the contentMode of the cell's Imageview
like this,
cell.imageView.contentMode = /*(something from the below list)*/;
typedef enum {
UIViewContentModeScaleToFill,
UIViewContentModeScaleAspectFit,
UIViewContentModeScaleAspectFill,
UIViewContentModeRedraw,
UIViewContentModeCenter,
UIViewContentModeTop,
UIViewContentModeBottom,
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight,
} UIViewContentMode;
精彩评论