views:

119

answers:

2

I want to show some images and text in a UITableView.

But when I add the image to its UITableViewCell it breaks the layout and overlaps with the next Header.

How can I set the size of the cell containing the image, so that the layout doesn't get broken?

I found some ObjC-Code which suggest this can be done by using heightForRowAtIndexPath, but I couldn't find anything MonoTouch specific.

A: 

Check out this blog post. It is dynamically resizing table cells for text but you can apply this for your images.

Kevin McMahon
Thanks, that was helpful.Basically it comes down to inheriting your own UITableViewDelegate and using that for your UITableView so that you get asked for the height of each row via GetHeightForRow.
Mike
A: 

If all of your cells are the same height, set the rowHeight property of your UITableView. Otherwise, use the UITableViewDelegate method:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

That's what you do in CocoaTouch/Obj-C. How you convert from native Obj-C into something that will work in MonoTouch, I have no idea. Good luck with that. :-)

Nick Forge