注冊和不注冊的區(qū)別主要看下面這兩個方法:
- (nullable __kindof UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier;
// Used by the delegate to acquire an already allocated cell, in lieu of allocating a new one.
(返回給代理一個已經(jīng)分配的cell,代替一個新的cell癌瘾,如果沒有已分配的cell杜窄,則返回nil,使用這個方法就不需要注冊了)
- (__kindof UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(6_0);
// newer dequeue method guarantees a cell is returned and resized properly, assuming identifier is registered
如果cell的identifier是注冊過的警医,那么這個新列出的方法保證返回一個cell (有分配的就返回已分配的cell,沒有返回新的cell)并適當調(diào)整大小,可省略cell空值判斷步驟滔迈,用這個方法cell必須注冊,不是自定義的cell揩懒,UITableViewCell也要注冊
個人博客地址:https://youyou0909.github.io