First, it should be clear that there are two kinds of headerview in TableView, one is Tableheaderview and the other is Headerview. The former is one; the latter depends on the number of sessions
The recycling of Headerview is similar to that of cell recycling, and it can also be registered with the following code:
Two. In the best project, Headerview only displays text, but only one label can not adjust the spacing to the left of the text. So consider wrapping a layer of view. A custom Headerview wrapper was rewritten, overriding the Headerview
-(instancetype) Initwithreuseidentifier: (nsstring *) Reuseidentifier; method, code is as follows:
To simplify the code, the code that creates the Headerview is also encapsulated, providing a way for the outside world to return Headerview with a parameter of TableView;
Implementation of the method:
External calling code:
iOS Development Tips--tableview Headerview recycling, and custom Headerview