关于tableView中的细节

这里总结一些tableview中的不经常使用的Tips

1.设置分区各分分区的title

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;

2.设置索引(就是左边的那一小列)

- (NSArray<NSString *> *)sectionIndexTitlesForTableView:(UITableView *)tableView;

注意:返回值是数组,要将索引存到数组里

3.设置点击cell后取消被选状态

>方法1:比较麻烦的方法  

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    [tableView deselectRowAtIndexPath:indexPath animated:YES];

}

这个方法的显示效果是在选中后,又明显的选中操作,之后消失的

>方法2:设置属性

cell.selectionStyle=UITableViewCellSelectionStyleNone;

设置后,选中和没选中的UI效果是一样的

4.未完待续

 

追寻最真
原文地址:https://www.cnblogs.com/zhao-jie-li/p/5046513.html