Uicollectionview load Way and tableview very much like, basically load the method is almost, especially its data source method and proxy method basically similar, but is the name of a slight difference. This is not a repeat.
1. Uicollectionview Why do you want to customize the group header and the end of the group? The reason is because if you do not customize, the system will reuse the cell, causing the loaded control to repeat itself.
such as: Green view for the group header, through the view found that the group header above the controls appear superimposed phenomenon.
How to solve the problem of the above reuse, using the method of initWithFrame initialization view, when the view on the cell is created, the control is created.
Solution Ideas:
A. Customizing the group header method
B. Create a control when the group header view is displayed
C. Incoming data override set method
Final Run effect
Since this customization method is simple, it is not explained in detail here.
2. The following focus is on how to use the Xib method to create a group header or a group footer control.
Here is an example of creating a tail view control:
1. Manually create an empty xib that inherits from the REUSABLEVIW
2. Create a good xib be sure to reuse identifiers
3. Create a custom Indexpath property in the. h file
Overriding this method in a 4..M file this is the lable in the Xib control lable
5. The custom tail view file and Xib have been created so far, so go back to the main function to implement the loading method
Note: The setting of the group header and the end of the group frame must be implemented in the proxy method, if not in the proxy method, the setting is not valid for the specific settings such as
6. Because it is a code-created CollectionView, you must register
A. The method of registering a group header implements the following code in Viewdidload
B. Methods for registering the end of a group
First of all there is a bug, if you follow the above registration method to register the end of the word is not possible, because the group header is not xib, so you can use the above method, and our group tail method is implemented by Xib way, so to load Xib file.
There's a little bug in here, first.
When using nib to register, in the form of the creation of the group header, you will find a popup??
The reason is that there is no way to find the initialization of the end of the group, how to solve it?
Such as:
That is, when I use the Xib method to create a group footer or a group header, it cannot be loaded using the class name +class, and must be created using the system's original class name.
Final Run
Uicollectionview Xib method for customizing the end of group header