开发者

How to set the cell.imageview frame

I have table view in which I want my Image view to reset the frame

I used the following code:

[[cell imageView] setFrame开发者_C百科:CGRectMake(0,0,32,32)];

But nothing is working

Please let me know how to resize the default imageView section

Thanks


The best way is to add - (void)layoutSubviews to your cell subclass like this:

- (void)layoutSubviews {
    [super layoutSubviews];
    self.imageView.frame = CGRectMake(0.0f , 0.0f, 32.0f, 32.0f);
}


UITableViewCell have a fixed layout, depending on the style you use when you initialize it. You cannot change that layout, since the cell lays out its subviews as it prefers to have them.

If you want to use another layout, you'll have to make your own cell and use that. Quoting the documentation of UITableViewCell:

If you want a table cell that has a configuration different that those defined by UITableViewCell for style, you must create your own custom celle


If you want to resize it to show high resolution images on retina display, you can also save a second image with double resolution and name it with @2x postfix.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜