views:

651

answers:

2

I have setup custom UITableViewCell from code. In my cell, I have a "UITableViewCellAccessoryDisclosureIndicator". When highlighting the cell, it goes blue, and the accessory item turns white. So that's all good.

However, when tapped and a new view is pushed, the accessory item disappears. When I go back to the tableview the UITableViewCellAccessoryDisclosureIndicator is gone and tapping/holding down the finger on the same cell will not highlight it again.

It worked fine last week, but I simply cannot figure out what has prompted this issue suddenly. I can't see anything when I do an 'hg diff', so was hoping someone would direct me to a possible solution. If you need specific code, please let me know.

I have used atebits Fast Scrolling example code and done a lot of customization with it, but the basics (and highlighted BOOL) has remained the same.

PS. In my code, I have also noticed that the UITableViewCell does not stay highlighted when the new view is pushed. I have noticed that Apple's own example code, the cell is highlighted when the new view is pushed, and going back to the tableview the cell remains highlighted until the tableview is pushed all the way back into place. Any ideas here? Thx.

A: 

I'm not sure what the Fast Scrolling code is that you're referring to, but the table view cell should stay highlighted through a push and pop of a view controller, only deselecting immediately after the next controller is popped. In other words, the sequence of events should be:

  1. Receive touch event on a table view cell
  2. The cell selects (highlights blue)
  3. Push the new controller
  4. Any action(s) on the new controller
  5. Pop the new controller
  6. The cell deselects (fades from blue to white)

If this isn't happening for you, you're probably making a call to the UITableView method deselectRowAtIndexPath:animated: - this is the method responsible for deselecting cells in a table view programmatically. Make sure you don't have any extra calls to that method in your code.

As regards losing the disclousre indicator, make sure that your table view's data source isn't changing during a push or pop of a view controller. If the data source changes to another object that doesn't include a UITableViewCellAccessoryDisclosureIndicator in its generated cells, you won't see it when you refresh the table by pushing/popping a view, even when that cell is highlighted. (It may be diagnostically beneficial to display the table, wait a little while, then call [tableView reloadData] and see if your accessory indicators disappear.)

Tim
I added:- (void)viewWillAppear:(BOOL)animated { NSIndexPath *selectedRowIndexPath = [self.tableView indexPathForSelectedRow]; if (selectedRowIndexPath != nil) { [self.tableView deselectRowAtIndexPath:selectedRowIndexPath animated:YES]; }}Now the DisclosureIndicator is somewhat fine. It returns when cell is deselected or tableview is pushed.However, the row is still deselected as the new view is pushed. I'd like to get the effect of "which cell was visited" so cell stays highlighted. Also, as the view is pushed, the disclosure item disappears during animation still :(
Canada Dev
I'm not sure that you should really be adding calls to deselectRowAtIndexPath:animated:, but instead looking to remove them - did you already call this method anywhere? If not, can we see some relevant code from your app (like your implementations for tableView:didSelectRowAtIndexPath: and other navigation-relevant delegate methods)?
Tim
A: 

I JUST solved this problem for myself (this A.M.)

Try, for the sake of argument, to remove the LayoutSubviews method from your cell. I have found this to wreak havoc on accessory views. I have ended up removing that method from my cells, and positioning the elements in the initialization method.

Dutchie432
I don't have a LayoutSubviews method in my code :/
Canada Dev