iOS -- tableView相关

1. 取消Cell的高亮选中状态:
Cell是能被选中的,只是没有了选中时(highlight状态)的颜色

cell.selectionStyle = UITableViewCellSelectionStyleNone;

2. 取消Cell的分割线:
Cell分割线的属性设置(颜色separatorColor,长度separatorInset,等)

_myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;

3. 使用MJRefresh的时候有时会出现下拉刷新以后tableView回不了顶端的问题:
具体原因不明,不过有个有效方法:即在添加tableView之前先加一个frame={0,0,0,0}的view。

UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
[self.view addSubview:view];
//用这个方法来解决刷新界面掉出来的问题

4. 左滑删除当前行

#pragma mark - 编辑:左滑删除
-(NSString*)tableView:(UITableView*)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath*)indexpath{
return @"删除";
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
//删除操作:先删除数据源,再刷新视图
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        [self.dataArray removeObjectAtIndex:indexPath.row];
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationRight];
    }
}
- (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath{
//开始编辑前
    NSLog(@"编辑开始");
}
- (void)tableView:(UITableView *)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath{
//编辑完成后
    NSLog(@"操作完成");
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值