tableView 要顯示數據的時候, 要依賴數據源代理
必須實現三個方法
1.
tableView中
有多少組
numberOfSectionsInTableView:
2.
每一組有多少行
numberOfRowsInSection:
3.
每一行要顯示的內容
cellForRowAtIndexPath:
//
設置組頭和組尾
的
文本
titleForHeaderInSection:
titleForFooterInSection:
tableView 自身維護了一個緩存池
1. 定義重用標識符
2. 根據重用標識符到緩存中去找對應的cell
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
3. 對取到的cell 進行判斷, 如果找不到就重新實例化cell
實例化的時候, 一定要設置重用標識符 : identifier
if (nil == cell ) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
注意:
1.
一定要先修改數據源中的數據
2.
進行刷新
1.
刷新全部數據
[_tableView reloadData];
2.
刷新指定行
的
數據
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
[_tableView reloadRowsAtIndexPaths:@[indexPath]
withRowAnimation:UITableViewRowAnimationLeft];
//
是否隱藏
tableView
的狀態欄
- (BOOL)prefersStatusBarHidden {
return
YES;
}