A
A
Anton Agaltsov2016-05-28 19:39:28
iOS
Anton Agaltsov, 2016-05-28 19:39:28

How to make an image in a tablecell full width and dynamic height?

I can't figure out how to make the following construction correctly:
I make a cell in a table view. At the top of the cell is a full-width TextLabel, then a full-width Image, and after the picture, a description, also full-width.
The problem is that I can't figure out how to make the Image stretch in height without breaking the proportional picture.
As far as I understand, everything rests on the height of the cell.
How to make such a cell?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Petrushka, 2016-05-29
@petruska

If I understand you correctly, then it is done like this
You have a model in which the picture lies and its dimensions (let's say the server throws)
In the height for rov method, you get the size and count

G
German Polyansky, 2016-05-31
@f0r3s1

You need to hard-code the costlines in the cell so that everything is anchored to top, bottom, left, right and insert two lines in viewDidLoad into the table view controller:

self.tableView.rowHeight = UITableViewAutomaticDimension;
    self.tableView.estimatedRowHeight = 80.0;

You can put any value in the rowHeight parameter, the main thing is that it is not empty and preferably close to the approximate height of the cells.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question