zoukankan      html  css  js  c++  java
  • 为什么Tableviewcell创建时可以不判空

    dequeueReuseableCellWithIdentifier:与dequeueReuseableCellWithIdentifier:forIndexPath:的区别:

    1. 前者不必向tableView注册cell的Identifier,但需要判断获取的cell是否为nil;但是注册了可以不判空
    2. 后者则必须向table注册cell,即必须在使用前调用registerNib:registerClass:方法,可省略判断获取的cell是否为空,因为无可复用cell时runtime将使用注册时提供的资源去新建一个cell并返回

    注册后,cell复用为空时,会使用注册时的类调用- (instancetype)initWithStyle:withReuseableCellIdentifier: 自动创建cell

    总结:注册后都可以不用判空

  • 相关阅读:
    git学习
    Command Line
    python之测试
    python之模块
    python之函数
    python之类
    python之错误和异常
    python之迭代器和生成器
    python之字典和集合
    python之列表和元组
  • 原文地址:https://www.cnblogs.com/huaida/p/11608223.html
Copyright © 2011-2022 走看看