0

I'm having a problem with this. What I did was every cell in indexPath.row % 2 == 1 I want to set it to blank so there could be a margin. But now it looks like this:

enter image description here

I want to remove the ">" in the cell that serves as a margin. How to remove that and remove the highlight thing when pressed? When pressed it turns to grey.

And how to delete the cell with this logic since every row is in odd numbers but the actual object is still in their proper indexes.

Here's my code:

if (indexPath.row % 2 == 1) {
    UITableViewCell *cell2 = [tableView dequeueReusableCellWithIdentifier:CELL_ID2];

    if (cell2 == nil) {
        cell2 = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CELL_ID2];
        [cell2.contentView setAlpha:0];
        cell2.selectionStyle = UITableViewCellSelectionStyleNone;
        cell2.userInteractionEnabled = NO;

    }
    return cell2;
}
Rence
  • 55
  • 10
  • You might also take a look at [this link](http://stackoverflow.com/questions/6216839/how-to-add-spacing-between-uitableviewcell) for some other options for space between cells. – David Berry May 22 '14 at 16:13

3 Answers3

1

Just set cell2.accessoryType = UITableViewCellAccessoryNone;

Michael
  • 6,451
  • 5
  • 31
  • 53
0

You will need to set the accessaryType to UITableViewCellAccessoryNone

cell2.accessoryType = UITableViewCellAcessoryNone;

https://developer.apple.com/library/ios/documentation/uikit/reference/UITableViewCell_Class/Reference/Reference.html#//apple_ref/doc/c_ref/UITableViewCellAccessoryType

Jesse Black
  • 7,966
  • 3
  • 34
  • 45
0

You're pretty close:

if (indexPath.row % 2 == 1) {
    UITableViewCell *cell2 = [tableView dequeueReusableCellWithIdentifier:CELL_ID2];

    if (cell2 == nil) {
        cell2 = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CELL_ID2];
    }

    cell2.selectionStyle = UITableViewCellSelectionStyleNone;
    cell2.accessoryType = UITableViewCellAccessoryNone;

    return cell2;
}

Your cell configuration (if cell is nil) should contain the bare minimum of what you need because the cells get reused (dequeueReusableCellWithIdentifier:). So you need to configure every indepedant part of the cell when it is reused. Thus you need to set the properties you need for that row of the indexPath.

ColdLogic
  • 7,206
  • 1
  • 28
  • 46