I want to control what happens in my UITableViewCell
when it is highlighted.
I know it is possible in iOS 6.0 like so:
- (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath
But how I do it if I am targeting 5.0 and above?
Your best option on iOS 5 would be to use this method
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
Though this method is called only when the user taps and then lifts their finger off the cell (as explained here), but I am not aware of any other methods available in both 5.x and 6.x which you could use for this.
If you have a custom UITableViewCell you can override the
-(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
method which will be called when the touch is down on the cell (the highlighted
param will be YES) and when the touch is up or canceled(the highlight
parameter is NO).
Also this approach will work on iOS 3.0 and later.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With