Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:CGRectMake(0,0,32,32)];

But nothing is working

Please let me know how to resize the default imageView section

Thanks

like image 253
crystal Avatar asked Nov 28 '09 11:11

crystal


2 Answers

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);
}
like image 121
Sam Soffes Avatar answered Nov 15 '22 20:11

Sam Soffes


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

like image 21
Pascal Avatar answered Nov 15 '22 20:11

Pascal