-1

What is the use of Subclassing the Navigation Controller in swift IOS? How should I do the Subclassing the Navigation controller?

I currently created the Tab bar controller with the Navigation controller. How should achieve I this? Can anyone explain this?

  • If you do not know a use-case of subclassing a `NavigationController`, you most probably do not have to subclass it. What do you actually want to achieve? Show the code which you have tried to achieve it with and let us know what problems you have using it. – shallowThought Apr 27 '17 at 13:05
  • 1
    Here are some answers for you: http://stackoverflow.com/questions/39417907/custom-tab-bar-controller-with-navigation-bar, http://stackoverflow.com/questions/27422054/how-to-implement-tab-bar-controller-with-navigation-controller-in-right-way – Krunal Apr 27 '17 at 13:08
  • I have a task on subclassing the NavigationController.Can you explain what the purpose of it.I googled a lot but didn't get the fine answer. – Sathish Kumar Gurunathan Apr 27 '17 at 13:10
  • Its good if you want to lock rotation for a certain flow, like login flow – Sean Lintern Apr 27 '17 at 13:19
  • Your need to use navigation controllers and a tab bar controller does not require any subclassing of a navigation controller. – rmaddy Apr 27 '17 at 14:00

2 Answers2

1

One of the uses can be when you need to create several screens with the same background, and the background does not move when you navigate between screens. In this case you can set the background as a UINavigationController's view. Still no need to subclass it...

But when your background becomes more complicated, let's say it's a video playing in loop, controlling the playback of the video may become a UINavigationController's task. Since there is no way to change the code of UINavigationController, subclassing it becomes useful.

I'm pretty sure there are another cases for subclassing UINavigationController, but all of them are rare special cases.

Max Pevsner
  • 4,098
  • 2
  • 18
  • 32
0

I think you almost never need to subclass UINavigationController. Having said that, I have done it before when I used a custom container controller. I needed to know when view controllers were pushed and popped and used that to reconfigure view controllers/views in my custom container controller.

tmrog
  • 107
  • 1
  • 5
  • 1
    Not sure why this was down voted as I answered the question asked and gave an example of where you might subclass a UINavigationController. – tmrog Apr 27 '17 at 14:23