tableView显示detailTextLable需要注意的问题

来源:互联网 发布:淘宝小俞钱币 编辑:程序博客网 时间:2024/05/17 03:46

这个也是不注意就容易犯的错误,关键在于

- (void)registerClass:(nullable Class)cellClass forCellReuseIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(6_0);

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(nullableNSString *)reuseIdentifier NS_AVAILABLE_IOS(3_0)NS_DESIGNATED_INITIALIZER;

这两个方法,如果想显示副标题里的内容就不能再使用第一个方法.

另附:

如果不写第一个方法,需要注意区分判断

- (nullable __kindofUITableViewCell *)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

这两个方法的区别.
0 0
原创粉丝点击