![]() Complex user interfaces no longer need to be managed by a single view controller. View controller containment makes it much easier to keep view controllers lean. The master and detail view controllers are both child view controllers of the UISplitViewController instance. If the user taps an item in the master view controller, the item's details are shown in the detail view controller. Each of these classes implements a navigation paradigm that is commonly found in iOS, tvOS, and macOS applications.Ī UISplitViewController instance, for example, presents a master view controller on the left and a detail view controller on the right. As I mentioned earlier, UIKit includes a number of UIViewController subclasses that are container view controllers, such as UITabBarController, UINavigationController, and UISplitViewController. Benefits ReusabilityĪ key advantage of container view controllers is reusability. It only knows how to manage them and navigate between them. A tab bar controller is aware of its child view controllers, but it doesn't know or care what they display. The same is true for tab bar controllers. It knows how to manage a stack of view controllers and it doesn't know or care what each of its child view controllers displays. A navigation controller is highly reusable thanks to the container view controller architecture. That said, the child view controller continues to be responsible for its own view hierarchy and that is what gives container view controllers their power. The view of the child view controller becomes part of the parent view controller's view hierarchy. The parent view controller is responsible for setting the size and position of the view of each child view controller. It acts as the parent view controller of one or more child view controllers. In addition to managing a view, a container view controller also manages one or more child view controllers. What does that mean? A container view controller manages a view just like any other UIViewController subclass. Container View Controllersīoth UINavigationController and UITabBarController are container view controllers. ![]() It manages an ordered list of view controllers accessible through a tab bar at the bottom. The same is true for a tab bar controller. You can push and pop view controllers onto and from a navigation stack. A navigation controller, for example, manages a stack of view controllers. What have these classes in common? Both classes allow you to insert custom content in the form of one or more view controllers. Have you ever wondered how tab bar controllers and navigation controllers do their work? Even though it may seem as if UITabBarController and UINavigationController are magical classes, they are nothing more than UIViewController subclasses.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |