A
A
Alexander Zarochintsev2014-04-14 17:30:02
Objective-C
Alexander Zarochintsev, 2014-04-14 17:30:02

How to correctly calculate the height and place the constraints?

Good time of the day! In general, there is a cell of the following form, picture - 1.
Picture - 1
6b8cc31edad486298644d5800485015e.png
Where: The
photo on the left is the user's photo;
Title - title;
Message - the message that the user left (may or may not be)
At the bottom of the photo - the photo that the user left (may or may not be)
And now I have a problem with the fact that the photo and message can be, or maybe and not to be, how to correctly place the constraints so that everything goes on normally with a photo / without a message / without?
With the Left photo and the title, everything is clear, I tie it up and to the left.
Help, please, otherwise I'm already tormented with this cell ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Morozov, 2014-04-14
@Kovalskiy

method on UITableViewDelegate

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
CGFloat height = 0;
height = 20; //высота от верхнего края ячейки до titleView
if (есть message) height += <посчитать высоту текста> + <отступ после текста>;
if (есть image) height += <посчитать высоту image> + <отступ после image>;
return height;
}

UPD:
so that the cell does not jump for all views, you need to set AutoresizingMask: (FlixebleRight | FlixebleBottom)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question