When i am select any row of navigation screen it is highlighted with Blue color. I want to keep this row selected with blue color when i am came to screen by back button. Mean when i am go to previous screen by back button, it should be indicated that which row is selected.
A:
// Save the currently selected row before navigating to a new view
- (NSIndexPath *)indexPathForSelectedRow;
// Select the row in viewDidLoad when returning to view
- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UITableViewScrollPosition)scrollPosition;
Aaron Saunders
2010-07-13 06:19:12
There's no need to do either of these since it already does this for you. If you wanted to highlight a *different* row other than the one you selected prior to pushing on a new view, then yes you could do something like this (but in `viewWillAppear` not in `viewDidLoad`)
iWasRobbed
2010-07-13 13:41:47
A:
Dhavi,
Please know that Apple's HIG (here) recommend de-selecting the row after the view is pushed back.
If you really want to leave it highlighted, just don't implement anything to de-select it in didSelectRowAtIndexPath
... What happens is when you de-select the row with say, this code:
[tableView deselectRowAtIndexPath:indexPath animated:YES];
the table will select it as blue (or gray or whatever customization you used), push the new view onto the stack, and then when you hit the back button it will briefly still show that cell as being highlighted to give your user a visual reference to where they were. If that code isn't in didSelectRowAtIndexPath
, then it won't be de-selected.
iWasRobbed
2010-07-13 13:39:52
I simply answered his question...there is no need to be so arrogant as to demote someone's answer
Aaron Saunders
2010-07-13 13:46:21
Aaron, my apologies, but it's not about arrogance. Downvoting is used only in instances where an answer is incorrect or off-topic. In your instance, your answer was incorrect. Please refer to this thread for more information: http://meta.stackoverflow.com/questions/7237/how-does-reputation-work
iWasRobbed
2010-07-13 13:54:36
my response is to let the person who "asked" the question determine if it was unhelpful or not.I am not certain the answer was incorrect per se since there is very little content provided in the question, and no codeAnd finally, I am aware of how reputation works, but thank you for the refresher.
Aaron Saunders
2010-07-13 14:08:22
This is a community site, both the community and the user decides. If you take offense to this, then you should realize that it's not personal. It's about delivering the best answer to help someone and ease their confusion. If an answer causes even more confusion or leads them in the wrong direction, anyone can downvote it as unhelpful. It's wrong to downvote others as a retaliatory gesture, especially when you yourself question **I am not certain the answer was incorrect**. There is a nav controller and a tableviewcontroller, that's all you need to know to help.
iWasRobbed
2010-07-13 14:36:14
+1
A:
Set the tableview controller's clearsSelectionOnViewWillAppear
property to NO (only available on iOS 3.2 and later).
Brian
2010-07-13 14:01:37