UITableViewCell highly dynamic configuration

UITableViewController Is quite a common space in the iOS development,It's very early cell can support highly adaptive,Or is highly dynamic。In development,If the cell in the complex layout of content - such as a micro-blog even drawing with the word。Well, this time automated highly dynamic becomes very useful - you do not have to calculate the total。

In fact, many people will not use this highly dynamic,Some people even use the time to initialize itself a new cell,Then write the same content with the current cell,Get its height and return...?‍♂️

In short,We now look at how to properly configure the cell height of the tableview。

Configuration Properties

First of all,You give TableView Open the automatic height function:

Note that the first line 88 ,You should give you all you need for a high degree of automatic cell possibleaverage value。

Remove the custom height

If you are editing prototype Which of course opened the height of the cell - for the convenience of layout you certainly do,so,Note uncheck it:

Cancel cell custom height

To establish cell can infer the height of the layout

Here it is very interesting,You must pay attention,Your layout in the cell if inappropriate,Then the cell will not be able to dynamically infer the required height according to your content!

Specifically how to do it? According to your past experience,When your content to be highly automated layout according to the content view to OK it,If you change the height up and down the cell contents and indifferent,That even if you turn on automatic height,The final cell can not deduce the height you need。

It is worth mentioning things

How to make UILabel It supports multi-line? Set its number of lines 0 .;

How to make UILabel Support rich text? Select the text attributedText .。

Extended reading

UITableViewCell highly adaptive key points

Original article written by LogStudio:R0uter's Blog » UITableViewCell highly dynamic configuration

Reproduced Please keep the source and description link:https://www.logcg.com/archives/2697.html

About the Author

R0uter

The non-declaration,I have written articles are original,Reproduced, please indicate the link on this page and my name。

Leave a Reply

Your email address will not be published. Required fields are marked *