In every UITableViewCell of a UITableView I'm placing an image in its imageView. However, if I increase the height of a cell using tableView:heightForRowAtIndexPath: to accomodate more text, I've found that:
I'd like the image to be top-aligned vertically, so that it is in the upper-left corner of the cell (like the first cell in the image below) and not have its left margin increased (so that the left margin of the text in the second cell aligns with the text in the first cell).
Altering the frame, center, etc. of the imageView seems to have no affect. Any ideas? Thanks...
(I have an image of the problem, but SO won't let me post an image yet because I'm a noob with less than 10 reputation. Grrr...)
You need to subclass UITableViewCell and override layoutSubviews, as follows:
- (void) layoutSubviews
{
[super layoutSubviews];
self.imageView.frame = CGRectMake( 10, 10, 50, 50 ); // your positioning here
}
In your cellForRowAtIndexPath: method, be sure to return an instance of your new cell type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With