views:

44

answers:

2

Hey all,

How can I give a tableView cell background color the fade effect as soon as it appears. I know how to get a cell selected when the table view appears but the color persists for ever. I would like it to stay there for a while (2 seconds or whatever) and then fade away.

Someone said that I should use [tableView performSelector] so I wrote this:

-(void) viewdidLoad {
    [tableView performSelector:@(highlight) withObject:nil afterDelay:2];
}

-(void) highlight
{
//I have a row selected as soon as my view appears

    -[tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES];
}

But when I used it, my application crashed. I think the crashing has something to do with the "withObject" attribute.

Can anyone help me with this?

A: 

The - highlight method belongs to your controller object, not to the table view. If you change tableView to self in the second line, it should stop the app crashing.

grahamparks
it still doesn't work
Bogus Boy
A: 
-(void)viewDidAppear:(BOOL)animated {
    [self performSelector:@selector(highlight) withObject:nil afterDelay:5];
    [super viewDidAppear:animated];
}
-(void)highlight{
   [tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES];
}

That worked for me, i think you may have missed out @selector() in performSelector. Be careful with the delay as keeping table cells selected after navigating back to the view is not recommended in Apples UI guidelines (as far as i can remember).

swaterfall