views:

20

answers:

1

Hello All,

I am facing a very strange problem with editingStyleForRowAtIndexPath method. I am planing to change the appearance of editable cells. It was working fine, but when i scroll the table i am not getting the table cell pointer in the editingStyleForRowAtIndexPath delegate method. So the new cells does not get the custom appearance.

I am using this -

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 
{

    // get tablviewcell pointer
    UITableViewCell* pCell = [tableView cellForRowAtIndexPath:indexPath]; // <- not getting the pointer when scrolling the table and new cells come up 

        //Changin cell appearance here ... 




}

Thanks in advance!

A: 

I think the table view may call this method before it assigns a cell to the given index path. A more reliable way to customize table view cells would be to override -tableView:willDisplayCell:forRowAtIndexPath:. You can test the cell's editingStyle property there and act accordingly.

Costique
Hello Costique,I just checked this and found that the methods execute in this order1)- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath2) - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath3) -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPathBut i am not able to get the cell in the 3rd method itself. Please help!!
Saurabh
Strange. What does the table view send as the cell parameter (the second one) in -tableView:willDisplayCell:forRowAtIndexPath:? Is the method called at all? If not, check if the object implementing the method is actually the table view's delegate.
Costique