views:

247

answers:

2

Is there any way of changing the UITableViewCellAccessory in the didSelectRowAtIndexPath function?

I need to change a "play"-icon to a "stop"-icon..

Thanks :)

A: 

You can get a pointer to the table cell in question by using the method

cellForRowAtIndexPath:

and passing the indexPath that is passed in as a parameter to didSelectRowAtIndexPath: and then change it's accessoryView property. Like this:

UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
[cell setAccessoryView:stopIconView];

Where stopIconView is likely to be a UIImageView or something.

Jasarien
Ok, so I did what you said, but I get an error:`Request for member 'tableViewThing' in something not a structure or union`Do you know why?
Emil
Whichever class you tried to access `tableViewThing` on, obviously doesn't have a `tableViewThing` property. What is `tableViewThing`? This should be a separate question if it's not related to the table view cell retrieval
Jasarien
A: 

Might be worth looking at the accessoryView property in UITableViewCell and see if it is possible to add an image to it.

willcodejavaforfood