我的tableView有多个部分。我想在行之间有分隔符但不希望在节的最后一行下面有分隔符。我怎样才能实现它?
我的代码也删除了一个内部分隔符。
NSInteger totalRow = [tableView numberOfRowsInSection:indexPath.section];
if (indexPath.row == totalRow -1)
{
//v1 of code
UILabel *l = [[UILabel alloc]init];
CGRect r = cell.bounds;
r.origin.y = r.origin.y + r.size.height - 2;
l.frame = r;
l.backgroundColor = [UIColor greenColor];
[cell.contentView addSubview:l];
cell.separatorInset = UIEdgeInsetsZero;
//v2 of code
cell.separatorInset = UIEdgeInsetsMake(10000.f, 0.f, 0.f, 1000);
_http://i60.tinypic.com/15xpyqp.png
我创建这样的单元格:
UITableViewCell *cellL;
switch (indexPath.section) {
case 0:
{
switch (indexPath.row) {
case 0:
{
static NSString *CellIdentifier = @"PopPushCellIdentifier";
PopPushCell *cell = (PopPushCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.pushTypeOn = YES;
cell.style = 5;
cell.titleLabel.text = [self returnTitleForCellWithTag:cell];
return cell;
}
break;
case 1:
{
static NSString *CellIdentifier = @"TextFieldCellIdentifier";
TextFieldCell *cell = (TextFieldCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.style = 4;
cell.titleLabel.text = [self returnTitleForCellWithTag:cell];
return cell;
}
break;
答案 0 :(得分:0)
实现它的一种方法是在细胞上插入1像素高度的UIView。引用它(在Interface Builder上链接)并在委托上隐藏或不隐藏它。