Reputation: 12607
I created and fulfilled UITableViewCell. I want to update textLabel.text at fifth row when I pressed UINavigationButton. How can I do this?
UITableViewCell *cell;
cell = [tableView_ dequeueReusableCellWithIdentifier:@"any-cell"];
if(cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"any-cell"] autorelease];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
cell.textLabel.text = leftString;
Upvotes: 7
Views: 7061
Reputation: 122401
You'll can tell the UITableView
to refresh that row (with reloadRowsAtIndexPaths:withRowAnimation:
) in the method that is handling the button edits.
Then have a special case in your UITableViewDataSource
method cellForRowAtIndexPath:
.
EDIT: I deleted this answer after seeing @EmptyStack's answer, which looked good to me. Perhaps this answer will cover his suggestion of updating the DataSource?
Upvotes: 0
Reputation: 51374
The direct way is,
NSIndexPath *fifthRow = [NSIndexPath indexPathForRow:4 inSection:0];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:fifthRow];
cell.textLabel.text = @"the updated text";
But, the better way is to update the dataSource and reload the tableView or just the row.
Upvotes: 15