IPhone Cannot deselect UITableViewCell

I have a RootViewController class that inherits from UITableViewController. When a cell is canceled by the user, I want to enable / disable certain buttons on the toolbar.

How to block the deselection event?

-(void)tableView:(UITableView *)tableView deselectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated
{
    if(indexPath.row <= rowNumber)
    {
        [viewButtton setEnabled:NO];
        [editButtton setEnabled:NO];
    }
}

      

I tried using this method but it doesn't work at all. Any ideas on how to do this?

+1


source to share


2 answers


I don't think there is a deselectRowAtIndexPath event, there is a method you can call to deselect the indexPath, but looking at the SDK I don't see an event for that in the UITableViewDelegate: http://developer.apple.com/iPhone/library /documentation/UIKit/Reference/UITableViewDelegate_Protocol/Reference/Reference.html .

Could you enable or disable certain buttons on the toolbar during the didSelectRowAtIndexPath: event?



-Rog

+1


source


This is only in the current beta SDK, which means it may be buggy / changed / unsupported ...

I noticed that your method declaration is not SDK compliant (at least the version I have).

Try to remove animated:(BOOL)animated

; I don't think this applies here.

See line ~ 345 in UITableView.h

and / or right click on didDeselectRowAtIndexPath

and Go to Definition, where you will probably find a way to define a delegate method.



However, if your goal is simply to "enable / disable certain buttons on cell selection"

- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath;

      

should work fine. This will happen after selecting a cell and before canceling it. Deselect should do more with animation than user interaction. The only reason I can think you want to use deselection is maybe the aesthetic value of ensuring that your event only occurs after the selection box is no longer highlighted.

0


source







All Articles