UITableView常用代理數(shù)據(jù)源方法調(diào)用順序及執(zhí)行次數(shù)

說(shuō)明:先執(zhí)行第一模塊(3次)、然后執(zhí)行第二模塊(section * row 次)、最后執(zhí)行第三模塊(section 次)

第一模塊:(1執(zhí)行完之后,循環(huán)執(zhí)行2-5 section次),整個(gè)模塊執(zhí)行3次后才執(zhí)行第二模塊

{
    1.有幾組 1次  numberOfSectionsInTableView
        【
            2.組頭高 2次  heightForHeaderInSection
            3.組尾高 2次  heightForFooterInSection
            4.有幾行 1次  numberOfRowsInSection
            5.每行高 row次 heightForRowAtIndexPath
          】section次
} 3次

第二模塊:整個(gè)模塊循環(huán)執(zhí)行section*row次之后才執(zhí)行第三模塊

{
    6.每行是啥 1次 cellForRowAtIndexPath
    7.每行高  1次 heightForRowAtIndexPath
    8.已展示行 1次 willDisplayCell
} section * row 次

第三模塊:整個(gè)模塊循環(huán)執(zhí)行section次

{
    9.組頭是啥    1次  viewForHeaderInSection
    10.已展示組頭 1次  willDisplayHeaderView
    11.組尾是啥  1次  viewForFooterInSection
    12.已展示組尾 1次  willDisplayFooterView
} section 次

UITableView滾動(dòng)到頂部和滾動(dòng)到底部的處理

if (_dataArr.count > 0) {//滾動(dòng)到頂部
        [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1] atScrollPosition:UITableViewScrollPositionTop animated:YES];
    }else{//滾動(dòng)到底部
        if (self.tableView.contentSize.height > self.tableView.frame.size.height){
            CGPoint offset = CGPointMake(0, self.tableView.contentSize.height - self.tableView.frame.size.height);
            [self.tableView setContentOffset:offset animated:NO];
        }
    }
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容