今天閑來無事總結(jié)了一下:tableView中用到的比較多的屬性
可能只需要修改一下,就省下很多行代碼:
//這句話不顯示多余的單元格
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
// 這句話不顯示單元格之間的分割線
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
// 這句話在單元格的最后顯示一個(gè)箭頭
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
//--- 點(diǎn)擊cell的時(shí)候 cell不會產(chǎn)生高亮狀態(tài) ---
cell.selectionStyle = UITableViewCellSelectionStyleNone;
// --- 寫在viewdidload里面cell自適應(yīng)高度 ----
tableView.rowHeight = UITableViewAutomaticDimension; // 自適應(yīng)單元格高度
tableView.estimatedRowHeight = 50; //先估計(jì)一個(gè)高度
// 去掉UItableview headerview黏性(sticky)
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat sectionHeaderHeight = 40;
if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {
scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
}
else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
}
}
// 獲取手勢點(diǎn)擊的是哪一個(gè)cell的坐標(biāo)
NSIndexPath *indexPath = [self.tableView indexPathForCell:((UITableViewCell *)longPress.view)];
// 局部刷新
//一個(gè)section刷新
NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:2];
[tableview reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];
//一個(gè)cell刷新
NSIndexPath *indexPath=[NSIndexPath indexPathForRow:3 inSection:0];
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
// 關(guān)于UITableView如何跳轉(zhuǎn)到最后一行或者任意指定行。
其實(shí)現(xiàn)如下:
[self.chatTableView scrollToRowAtIndexPath:
[NSIndexPath indexPathForRow:[self.chatArray count]-1 inSection:0]
atScrollPosition: UITableViewScrollPositionBottom
animated:NO];
// 點(diǎn)擊button時(shí)獲取button所在的cell的indexpath
UIButton *button = sender;
HeroDermaTableViewCell *cell = (HeroDermaTableViewCell *)[[button superview] superview];
NSIndexPath *indexPath = [_tableView indexPathForCell:cell];
UIView *backView = [[UIView alloc] initWithFrame:self.bounds];
self.selectedBackgroundView = backView;
self.selectedBackgroundView.backgroundColor = [UIColor clearColor];
將UITableVIew 的屬性 allowsSelectionDuringEdinting 設(shè)置為 TRUE,之后就可在編輯模式下,調(diào)用點(diǎn)擊方法了。
self.tableView.allowsSelectionDuringEditing=YES;
后續(xù)繼續(xù)更新