標(biāo)簽:UITableView-------表視圖--繼承UIScrollView并遵守NSCoding協(xié)議
屬性
frame-------------設(shè)置控件的位置和大小
backgroundColor--------設(shè)置控件的顏色
style--------獲取表視圖的樣式
dataSource---------設(shè)置UITableViewDataSource的代理
delegate---------設(shè)置UITableViewDelegate代理
sectionHeaderHeight------設(shè)置組表視圖的頭標(biāo)簽高度
sectionFooterHeight--------設(shè)置組表視圖的尾標(biāo)簽高度
backgroundView----------設(shè)置背景視圖,只能寫入
editing----------是否允許編輯,默認(rèn)是NO
allowsSelection----------在非編輯下蔽氨,行是否可以選中,默認(rèn)為YES
allowsSelectionDuringEditing----------控制某一行時帆疟,是否可以編輯鹉究,默認(rèn)為NO
allowsMultipleSelection--------是否可以選擇多行,默認(rèn)為NO
allowsMutableSelectionDuringEditing----------在選擇多行的情況下踪宠,是否可以編輯自赔,默認(rèn)為NO
sectionIndexMinimumDisplayRowCount-------------顯示某個組索引列表在右邊當(dāng)行數(shù)達到這個值,默認(rèn)是NSInteger的最大值
sectionIndexColor------------選擇某個部分的某行改變這一行上文本的顏色
sectionIndexTrackingBackgroundColor--------設(shè)置選中某個部分的背景顏色
separatorStyle----------設(shè)置單元格分隔線的樣式
separatorColor---------設(shè)置選中單元格分隔線的顏色
tableHeaderView---------設(shè)置組表的頭標(biāo)簽視圖
tableFooterView----------設(shè)置組表的尾標(biāo)簽視圖
UITableView類目屬性
section--------獲取當(dāng)前在哪個組內(nèi)
row------------獲取當(dāng)前單元格是第幾行
方法:
初始化方法:
initWithFrame:-----------設(shè)置表的大小和位置
initWithFrame:style---------設(shè)置表的大小殴蓬,位置和樣式(組匿级,單一)
setEditing:----------表格進入編輯狀態(tài),無動畫
setEditing: animated:---------表格進入編輯狀態(tài)染厅,有動畫
reloadData---------------刷新整個表視圖
reloadSectionIndexTitles--------刷新索引欄
numberOfSections-----------獲取當(dāng)前所有的組
numberOfRowsInSection:---------獲取某個組有多少行
rectForSection:----------獲取某個組的位置和大小
rectForHeaderInSection:---------獲取某個組的頭標(biāo)簽的位置和大小
rectForFooterInSection:-----------獲取某個組的尾標(biāo)簽的位置和大小
rectForRowAtIndex:-----------獲取某一行的位置和大小
indexPathForRowAtPoint-------------點擊某一個點痘绎,判斷是在哪一行上的信息。
indexPathForCell:------------獲取單元格的信息
indexPathsForRowsInRect:---------在某個區(qū)域里會返回多個單元格信息
cellForRowAtIndexPath:-------------通過單元格路徑得到單元格
visibleCells-----------返回所有可見的單元格
indexPathsForVisibleRows--------返回所有可見行的路徑
headerViewForSection:--------設(shè)置頭標(biāo)簽的視圖
footerViewForSection肖粮;----------設(shè)置尾標(biāo)簽的視圖
beginUpdates--------只添加或刪除才會更新行數(shù)
endUpdates---------添加或刪除后會調(diào)用添加或刪除方法時才會更新
insertSections:withRowAnimation:-----------插入一個或多個組孤页,并使用動畫
insertRowsIndexPaths:withRowAnimation:-------插入一個或多個單元格,并使用動畫
deleteSections:withRowAnimation:--------刪除一個或多個組涩馆,并使用動畫
deleteRowIndexPaths:withRowAnimation:--------刪除一個或多個單元格行施,并使用動畫
reloadSections:withRowAnimation:---------更新一個或多個組允坚,并使用動畫
reloadRowIndexPaths:withRowAnimation:-------------更新一個或多個單元格,并使用動畫
moveSection:toSection:-------------移動某個組到目標(biāo)組位置
moveRowAtIndexPath:toIndexPath:-----------移動個某個單元格到目標(biāo)單元格位置
indexPathsForSelectedRow----------返回選擇的一個單元格的路徑
indexPathsForSelectedRows---------返回選擇的所有的單元格的路徑
selectRowAtIndexPath:animation:scrollPosition---------設(shè)置選中某個區(qū)域內(nèi)的單元格
deselectRowAtIndexPath:animation:----------取消選中的單元格
重用機制
dequeueReusableCellWithIdentifier:---------獲取重用隊列里的單元格
UITableViewDataSource代理方法:
方法:
numberOfSectionsInTableView:------------設(shè)置表格的組數(shù)
tableView:numberOfRowInSection:----------設(shè)置每個組有多少行
tableView:cellForRowAtIndexPath:---------設(shè)置單元格顯示的內(nèi)容
tableView:titleForHeaderInSection:---------設(shè)置組表的頭標(biāo)簽視圖
tableView:titleForFooterInSection:-----------設(shè)置組表的尾標(biāo)簽視圖
tableView:canEditRowAtIndexPath:---------設(shè)置單元格是否可以編輯
tableView:canMoveRowAtIndexPath:--------設(shè)置單元格是否可以移動
tableView:sectionIndexTitleForTableView:atIndex:-------設(shè)置指定組的表的頭標(biāo)簽文本
tableView:commitEditingStyle:forRowAtIndexPath:----------編輯單元格(添加蛾号,刪除)
tableView:moveRowAtIndexPath:toIndexPath-------單元格移動
UITableViewDelegate代理方法:
tableView:? willDisplayCell: forRowAtIndexPath:-----------設(shè)置當(dāng)前的單元格
tableView: heightForRowAtIndexPath:-----------設(shè)置每行的高度
tableView:tableView heightForHeaderInSection:-----------設(shè)置組表的頭標(biāo)簽高度
tableView:tableView heightForFooterInSection:-------------設(shè)置組表的尾標(biāo)簽高度
tableView: viewForHeaderInSection:----------自定義組表的頭標(biāo)簽視圖
tableView: viewForFooterInSection: ----------自定義組表的尾標(biāo)簽視圖
tableView: accessoryButtonTappedForRowWithIndexPath:-----------設(shè)置某個單元格上的右指向按鈕的響應(yīng)方法
tableView: willSelectRowAtIndexPath:-----------獲取將要選擇的單元格的路徑
tableView: didSelectRowAtIndexPath:-----------獲取選中的單元格的響應(yīng)事件
tableView: tableView willDeselectRowAtIndexPath:------------獲取將要未選中的單元格的路徑
tableView: didDeselectRowAtIndexPath:-----------獲取未選中的單元格響應(yīng)事件
執(zhí)行順序如下:
第一輪:
1稠项、numberOfSectionsInTableView? ? :假如section=2,此函數(shù)只執(zhí)行一次鲜结,假如section=0展运,函數(shù)不執(zhí)行,默認(rèn)為1
2精刷、heightForHeaderInSection? 拗胜,執(zhí)行兩次,此函數(shù)執(zhí)行次數(shù)為section數(shù)目
3怒允、heightForFooterInSection? 埂软,函數(shù)屬性同上,執(zhí)行兩次
4纫事、numberOfRowsInSection? ? 勘畔,此方法執(zhí)行一次
5、heightForHeaderInSection? ? 儿礼,此方法執(zhí)行了兩次咖杂,我其實有點困惑為什么這里還要調(diào)用這個方法
6、heightForFooterInSection? 蚊夫,此方法執(zhí)行兩次诉字,
7、numberOfRowsInSection知纷,執(zhí)行一次
8壤圃、heightForRowAtIndexPath? ,行高琅轧,先執(zhí)行section=0伍绳,對應(yīng)的row次數(shù)
第二輪:
1、numberOfSectionsInTableView 乍桂,一次
2冲杀、heightForHeaderInSection? ,section次數(shù)
3睹酌、heightForFooterInSection? ? 权谁,section次數(shù)
4、numberOfRowsInSection? ? 憋沿,一次
5旺芽、heightForHeaderInSection? ,執(zhí)行section次數(shù)
6、heightForFooterInSection采章,執(zhí)行section次數(shù)
7运嗜、numberOfRowsInSection,執(zhí)行一次
8悯舟、heightForRowAtIndexPath担租,行高,先執(zhí)行一次
9图谷、cellForRowAtIndexPath
10翩活、willDisplayCell
然后8、9便贵、10依次執(zhí)行直到所有的cell被描畫完畢