В (скажем так) вертикали UICollectionView
,
Можно ли иметь ячейки полной ширины, но разрешить динамическую высоту для автоматического определения высоты?
(Если вы новичок в iOS, "динамическая высота" означает, что каждая ячейка может быть любой высоты, например, из-за текста или изображений.)
Мне кажется, что это, пожалуй, "самый важный вопрос в iOS без действительно хорошего ответа".
Это, безусловно,
самая сложная проблема во всех iOS :-(
Середина 2019 года... Я добавил еще одну награду - по-прежнему нет действительно хорошего решения этой основной проблемы.
WTH, Apple?
Важно - это академический вопрос - просто используйте табличное представление!
Около 50 000 человек изучили эту страницу! Как указывают xxtesaxx и другие,
... вы можете сделать это мгновенно, без усилий, с помощью таблицы.
В эти дни (2019 г.) вы ничего не делаете - вообще ничего - для представления таблицы, чтобы оно идеально работало с элементами динамической высоты в ячейках.
(Предполагая, что вы знаете, как правильно "связать" ячейку вверх и вниз по ограничениям, что является обязательным.)
Поэтому единственная причина сделать то, что просят на этой странице, - это пытка.
Опять же: имейте в виду, что в эти дни вы можете сделать это без особых усилий с обычным представлением таблицы!