这个也是不注意就容易犯的错误,关键在于
- (void)registerClass:(nullable Class)cellClass forCellReuseIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(6_0);
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(nullable NSString *)reuseIdentifier NS_AVAILABLE_IOS(3_0) NS_DESIGNATED_INITIALIZER;
这两个方法,如果想显示副标题里的内容就不能再使用第一个方法.
另附:
如果不写第一个方法,需要注意区分判断
- (nullable __kindof UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier; // Used by the delegate to acquire an already allocated cell, in lieu of allocating a new one.
- (__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
这两个方法的区别.
本文解析了UITableView中两种常见的单元格注册与复用方法,强调了如何正确使用这些方法来提高应用程序性能,并指出了常见误区及解决方案。
485

被折叠的 条评论
为什么被折叠?



