AnthonyR
AnthonyR

Reputation: 3545

After an insert into the UITableView : custom the cell

I'm using insertion into my UITableView with this :

 Skill * newSkill = [[Skill alloc] init];
    newSkill.name = @"Nouvelle compétence";
    newSkill.pathPicto = @"generic";
    [self.skills insertObject:newSkill atIndex:0];

    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
    [self.tableView beginUpdates];
    [self.tableView
     insertRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationTop];
    [self.tableView endUpdates];

It works great but now I want that the inserted cell be editable.

I would like that the label "Nouvelle compétence" can be edited and override with another text, and I would change the label color but I don't know how as the cell is inserted automatically. Maybe with a specific method before inserting ??

Upvotes: 0

Views: 43

Answers (1)

gyan
gyan

Reputation: 219

You need to use UITextField instead of UILabel. When you insert a new cell, set this UITextField's enabled property to true.

When loading all the other cells remember to set it to false to disable editing (the same cell maybe used at more than one place).

Upvotes: 1

Related Questions