美文网首页
UITableView

UITableView

作者: John易筋 | 来源:发表于2017-06-05 11:50 被阅读0次

    Question: Custom UITableViewCell initialization not called

    ** reference methods: **

    • init
    • initWithFrame
    • initWithStyle:reuseIdentifier:
    • initWithCoder:
    • awakeFromNib
    1. init not be called
    2. initWithFrame not be called
    3. If the cells come from a storyboard or nib file, call initWithCoder: firstly and call awakeFromNib later. Be careful initWithCoder: is availability (9.0 and later), tvOS (9.0 and later).
    4. If the cells come from coder registerClass:forCellReuseIdentifier:, call initWithStyle:reuseIdentifier: instead.
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
        if (self) {
            // self.contentView.bounds = [UIScreen mainScreen].bounds;
            // ...
        }
        
        return self;
    

    The answer can be found in the method description - (__kindof UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(6_0);

    Important
    You must register a class or nib file using the registerNib:forCellReuseIdentifier: or registerClass:forCellReuseIdentifier: method before calling this method.
    If you registered a class for the specified identifier and a new cell must be created, this method initializes the cell by calling its initWithStyle:reuseIdentifier: method. For nib-based cells, this method loads the cell object from the provided nib file. If an existing cell was available for reuse, this method calls the cell’s prepareForReuse method instead.
    

    优化UITableViewCell高度计算的那些事

    UITableViewCell 利用 AutoLayout 自动高度计算和 UITableView 滑动优化的一个总结。
    sunnyxx在维护一个开源的扩展,UITableView+FDTemplateLayoutCell,让高度计算这个事情变的前所未有的简单,也受到了很多星星的支持,github链接请戳我 https://github.com/forkingdog/UITableView-FDTemplateLayoutCell

    优化UITableViewCell高度计算的那些事 总结你可以读到:

    • UITableView高度计算和估算的机制
    • 不同iOS系统在高度计算上的差异
    • iOS8 self-sizing cell
    • UITableView+FDTemplateLayoutCell如何用一句话解决高度问题
    • UITableView+FDTemplateLayoutCell中对RunLoop的使用技巧

    相关文章

      网友评论

          本文标题:UITableView

          本文链接:https://www.haomeiwen.com/subject/vwsifxtx.html