My iOS app is current transferring control to a detail view when an item in a UITableView is selected. This ia a quiz program, and I’d like to change the app so that it just redisplays the same table view with the correct answer highlighted when a row is selected. What’s a good approach for doing this?
Share
Is not clear to me if you know why the detail view is appearing. So I’ll explain just in case. If you are giving control to a detail view is because somewhere in your code you are pushing that detail view. It depends on what kind of
UITableViewCellyou are using. If you are using one of the defaults styles, your detail view is probably been pushed in either:or
If you are using a custom cell, then you need to look for the method in charge of pushing
that detail view.
I think a good approach would be to:
Do something similar to the following on your
tableView:didSelectRowAtIndexPath:NSIndexPath.NSIndexPathto find the correct cell withcellForRowAtIndexPath:setSelected:animated:on that cell to highlight it.NOTE: If your quiz has more answers than the amount of
UITableViewCellsthat fit in the screen you should scroll yourUITableViewto the right answer for better UX.