WHAT I'M DOING
I'm developing an IOS Application with swift3 (coming from an existing android version). I have a UITableView which can have 3 types of views (as cells). One type will be the header and other represents diferent types (hours, photo or/and material). Take a look at the next image to clarify the schema:
WHAT I TRIED
After days of research, I tried a lot of possible solutions. These are the best intents:
- Static rows with different views:
https://stackoverflow.com/a/30776750/2131420 This is not a solution, because the number of views are static and i can't have random order of views (the app crashes if order was different... First the view 2, next the view 1, then view 2 again...)
- One view with all view types inside:
For the moment, this is the best try... This consist in draw one view with the 3 view types inside. One UIView (like container) for each view type.
Then, with code, set the height of the views to 0 with the unnecessary UIView (containers).
The problem of this method is the automatic dimension of the cells. Researching, i get than you can set NSLayoutConstraints to 0 for hidden. But, if you do it, the text gets cutted with the three points (...) I can't do this. Also, I tried to put the property lineBrake to "WordWrap" and lines to 0. This also does not solve the problem.
Image example:
THE QUESTION
How can I load different views into cell depending of value from array? And how can I set the height of this cells according to the height of the content?
Sorry for the english and thanks in advance!