Cell reuse methods and cell reuse methods
1. Use xib for Reuse
// Recommended reuse method after ios6
// Use self dynamically to obtain the current class name as a unique identifier
NSString * identifier = NSStringFromClass ([self class]);
UINib * nib = [UINib nibWithNibName: identifier bundle: nil];
// Register
[TableView registerNib: nib forCellReuseIdentifier: identifier];
// First go to the cache pool. If there is no reusable cell in the cache pool, create a cell object based on the previously registered nib and return it to you.
GPSubjectCell * cell = [tableView dequeueReusableCellWithIdentifier: identifier];
Return cell;
2. Pure code
// Ensure the uniqueness of the label. Using the class name is a good choice.
NSString * identifier = @ "GPSubjectCell ";
// 1. Check whether the cache pool can be reused.
GPSubjectCell * cell = [tableView dequeueReusableCellWithIdentifier: identifier];
// 2. If no reuse is available, create one by yourself.
If (cell = nil)
{
Cell = [[self alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: identifier];
}
Return cell;
3.
// Use the registration mechanism to reuse the cell class with pure code
NSString * className = NSStringFromClass ([self class]);
[TableView registerClass: [self class] forCellReuseIdentifier: className];
Return [tableView dequeueReusableCellWithIdentifier: className];
4. When using storyboard, (but a Identifier must be provided for the cell)
Return [collectionView dequeueReusableCellWithReuseIdentifier: @ "bookCell" forIndexPath: indexPath];