How do I make a UINavigationBar respond to taps?
-
22-07-2019 - |
Question
I have a tableViewController/navController setup. I want to tap on the navbar of the navController to force the tableView back to the top row. I can see that the navbar is a UIView subclass, but I am unclear if I need to subclass it and implement the touch sequence methods.
I've build the view hierarchy in IB so I am reluctant to build it all programmatically just to enable tapping of the navbar.
Thanks, Doug
Solution
The OS already defines the "tap on the status bar" gesture to mean "scroll to the top of the current view." UIScrollView
has a property scrollsToTop
that controls this behavior, and UITableView
inherits it.
OTHER TIPS
You can change what subclass any item is in interface builder. Just create your subclass, add it to your XCode project, and then you'll be able to enter it in as the class instead of the normal value.
For a simple example on how to override a class look here.