1

I am working with a MasterDetail View using SplitViewController in iPad, My Master View has a tableView where I add rows dynamically. So the newly added row sits at zero postion. So what I want to achieve is that, I want to select the newly added row as soon as it is added to the Master table. Later when the user adds a new row, that row should be selected and the previously added row should be deselected.

For this I have written the code below

- (void)selectNewlyAddedRow
{
            NSIndexPath* selectedCellIndexPath= [NSIndexPath indexPathForRow:0 inSection:0];
        [m_tableView selectRowAtIndexPath:selectedCellIndexPath animated:TRUE scrollPosition:UITableViewScrollPositionNone];
        [self tableView:m_tableView didSelectRowAtIndexPath:selectedCellIndexPath];
}

This code works if I write it in function ViewDidAppear, but if I write it in cellForRowAtIndexPath it doesnt work..

Please provide me correct understanding where I am going wrong.

Regards Ranjit

4

2 に答える 2