屬性:
rowHeight:行高
sectionHeaderHeight:表頭高度
sectionFooterHeight:表尾高度
estimatedRowHeight:估記高度 (iOS7)
estimatedSectionHeaderHeight:估計表頭高度(iOS7)
estimatedSectionFooterHeight:估計表尾高度 (iOS7)
separatorInset:分割線設定 (iOS7)
backgroundView:背景視圖
numberOfSections:表格包含多少個部分
visibleCells:顯示的儲存格 (取值為NSArray)
indexPathsForVisibleRows:可見單元的的索引 (取值為NSArray)
editing:是否允許編輯
allowsSelection:是否允許選中
allowsSelectionDuringEditing:是否能夠在編輯狀態下選中
allowsMultipleSelection:是否允許多選
allowsMultipleSelectionDuringEditing:是否允許在編輯狀態下多選
indexPathForSelectedRow:選中單元的的索引 (單個)
indexPathsForSelectedRows:選中的儲存格的索引 (單個或者多個 取值為NSArray)
sectionIndexMinimumDisplayRowCount:設定當表頭有多少個的時候顯示表頭索引 (取值為 NSInteger)
sectionIndexColor:選中的某個儲存格的文本顏色
sectionIndexBackgroundColor:選中的某個儲存格的背景顏色 (iOS7)
sectionIndexTrackingBackgroundColor:選擇某個部分的儲存格的持續背景顏色
separatorStyle:分割線形式 (UITableViewCellSeparatorStyleNone,UITableViewCellSeparatorStyleSingleLine,UITableViewCellSeparatorStyleSingleLineEtched )
separatorColor:分割線顏色
separatorEffect:分割線效果 (ios 8)
cellLayoutMarginsFollowReadableWidth :是否對風格線內容留白 (iOS9加入主要針對ipad)
tableHeaderView:表頭視圖
tableFooterView:表尾視圖
remembersLastFocusedIndexPath :。
方法:
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style;初始化方法同時設定表格模式
- (void)reloadData;重新整理資料
- (void)reloadSectionIndexTitles;重新整理索引
- (NSInteger)numberOfRowsInSection:(NSInteger)section;擷取某個組中的有多少行
- (CGRect)rectForSection:(NSInteger)section;擷取某個租的位置大小
- (CGRect)rectForHeaderInSection:(NSInteger)section;擷取表頭的位置大小
- (CGRect)rectForFooterInSection:(NSInteger)section;擷取表尾的位置大小
- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath;擷取儲存格的位置大小
- (nullable NSIndexPath *)indexPathForRowAtPoint:(CGPoint)point;點擊某個點擷取改點所在的儲存格的索引
- (nullable NSIndexPath *)indexPathForCell:(UITableViewCell *)cell;擷取儲存格索引
- (nullable NSArray<NSIndexPath *> *)indexPathsForRowsInRect:(CGRect)rect;zai'mou'g地區裡面返回多個儲存格的資訊
- (nullable __kindof UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath;通過儲存格索引擷取儲存格
- (nullable UITableViewHeaderFooterView *)headerViewForSection:(NSInteger)section;設定表頭視圖
- (nullable UITableViewHeaderFooterView *)footerViewForSection:(NSInteger)section;設定表尾視圖
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated;表視圖定位到某一行
- (void)scrollToNearestSelectedRowAtScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated;表視圖定位到選中行
- (void)beginUpdates;只添加或刪除才會更新行數
- (void)endUpdates;添加或刪除後會調用添加或刪除方法時才會更新
- (void)insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;插入一個或者多個組並是否使用動畫
- (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;刪除一個或者多個組並使用動畫
- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;更新一個或者多個組並使用動畫
- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection ;移動某個組到目標組
- (void)insertRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;插入一個或者多個儲存格並使用動畫
- (void)deleteRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;刪除一個或者多個儲存格並使用動畫
- (void)reloadRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation更新儲存格並使用動畫
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath移動儲存格到某個目標儲存格
- (void)setEditing:(BOOL)editing animated:(BOOL)animated;進入編輯狀態同時設定是否使用動畫
- (void)selectRowAtIndexPath:(nullable NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UITableViewScrollPosition)scrollPosition;設定選中某個地區的儲存格
- (void)deselectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated;取消選中的儲存格
- (nullable __kindof UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier; 擷取重用隊列裡面的儲存格
- (__kindof UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath;根據索引取出某行儲存格複用
- (nullable __kindof UITableViewHeaderFooterView *)dequeueReusableHeaderFooterViewWithIdentifier:(NSString *)identifier;設定隊列中的重用儲存格的標識符
資料代理:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; 設定表格行數
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;設定儲存格的顯示內容
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;設定表格組數
- (nullable NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;指定表格中指定某個組頭的標題
- (nullable NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section;指定表格中指定某個組尾的標題
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath;設定儲存格是否能夠編輯
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath;設定儲存格是否能夠移動
- (nullable NSArray<NSString *> *)sectionIndexTitlesForTableView:(UITableView *)tableView;右邊索引的標題
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index;點擊右邊索引的時候調用的方法
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath;編輯儲存格
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath;移動儲存格
代理:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;儲存格將要顯示
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section;組頭視圖將要顯示
- (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section;組表尾將要顯示
- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath*)indexPath;儲存格已經顯示
- (void)tableView:(UITableView *)tableView didEndDisplayingHeaderView:(UIView *)view forSection:(NSInteger)section;組頭視圖已經顯示
- (void)tableView:(UITableView *)tableView didEndDisplayingFooterView:(UIView *)view forSection:(NSInteger)section;組表尾已經顯示
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;儲存格高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;表頭高度
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;表尾高度
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath;估計儲存格高度
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section;估計表頭高度 (ios7)
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForFooterInSection:(NSInteger)section;估計表尾高度( ios7)
- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section; 設定表頭視圖(ios7)
- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section; 設定表尾視圖
- (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath;設定某個儲存格的右邊的形式
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath;某個儲存格右側按鈕的回應程式法
- (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath; 點擊狀態是否顯示高亮
- (void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath ;儲存格高亮狀態調用的方法
- (void)tableView:(UITableView *)tableView didUnhighlightRowAtIndexPath:(NSIndexPath *)indexPath;儲存格不是高亮狀態執行的方法
- (nullable NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath;將要選中儲存格執行的方法
- (nullable NSIndexPath *)tableView:(UITableView *)tableView willDeselectRowAtIndexPath:(NSIndexPath *)indexPath;將要取消選中執行的方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;選中儲存格執行的方法
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath;取消選擇儲存格執行的方法
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath;可編輯按儲存格的編輯形式
- (nullable NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath;儲存格刪除移動修改按鈕上面的文字
- (nullable NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath ;側滑顯示更多互動按鈕(ios8_0)
- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath;進入編輯狀態的時候儲存格不縮排
- (void)tableView:(UITableView*)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath;將要進入編輯狀態的時候執行
- (void)tableView:(UITableView*)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath 結束編輯狀態的時候執行;
- (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath;當前划過的cell位置是否可以被替換,如果不行則給出建議的位置
- (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath;行縮排
- (BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath;是否允許顯示長按詩的mune菜單
- (BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(nullable id)sender;是否每個儲存格都能在長按的時候顯示mune菜單
- (void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(nullable id)sender;對一個給定的行告訴代表執行複製或粘貼操作內容,
- (BOOL)tableView:(UITableView *)tableView canFocusRowAtIndexPath:(NSIndexPath *)indexPath(ios9);
- (BOOL)tableView:(UITableView *)tableView shouldUpdateFocusInContext:(UITableViewFocusUpdateContext *)(ios9);
- (void)tableView:(UITableView *)tableView didUpdateFocusInContext:(UITableViewFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator(ios9);
- (nullable NSIndexPath *)indexPathForPreferredFocusedViewInTableView:(UITableView *)tableView(ios9);