weky
weky

Reputation: 3

ios - different section with different cell.accessoryType

I have table with two sections, I want first section cells to have indicator, and second section cells no indicator.

I tried this:

    if (indexPath.section==1){

             cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    }else if(indexPath.section==2){

             cell.accessoryType = UITableViewCellAccessoryNone;
    }

and this:

   if(indexPath.section==1){

        switch(indexPath.row){

            default:
                cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

                break;

        }

    }else if(indexPath.section==2){

        switch(indexPath.row){

            default:
               cell.accessoryType = UITableViewCellAccessoryNone;

                break;

        }

    }

None worked with me, what did i do wrong?

Upvotes: 0

Views: 110

Answers (2)

Vinh Bui
Vinh Bui

Reputation: 1

do you use the same cell identifier? Did you try two different cell identifiers? Try to use 2 different one.

Upvotes: 0

Sulthan
Sulthan

Reputation: 130102

The index of the first section should be 0, not 1.
The index of the second section should be 1, not 2.

Remember that in (most) programming languages we are indexing from zero.

Upvotes: 4

Related Questions