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 开发者_StackOverflow社区should be indicated that which row is selected.
Set the tableview controller's clearsSelectionOnViewWillAppear
property to NO (only available on iOS 3.2 and later).
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.
// 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;
精彩评论