Why do UIViewControllers have xib files and no UIViews?

When I create a new UIViewController in xcode, it suggests making me a related nib for the interface. However, when I create a UIView, it is not. If my understanding of MVC is correct, views really should be parts that contain interface elements (like nib), while view controllers are parts that attach functionality to controlled views.

I'm sure I can get him to work together anyway, so this is more of a research question.

This is similar to the case when I lack a fundamental understanding of how these two parts should be used. What am I missing?

+3
source share
3 answers

The answer I eventually received satisfied my interest like this:

The task of the view controller is to manage the view hierarchy. The Builder interface is a great tool for creating presentation hierarchies. Xcode suggests creating .xib when creating a new view controller, because it is likely that you will want to load controller views from .xib.

Files

.xib is not necessarily intended to store every UIView (or subclass) that is included in the view, just a general view of the views that do not change throughout the life of the view. Other UIViews are much easier to create programmatically, as they often change.

0
source
0

. ( MVC) . iPhone , UIViewController "view", UIView.

XIB ( ) UIView. XML-, UIView . , UIViewController, UIView XIB .

UIView XIB, , , ...

0

Source: https://habr.com/ru/post/1768918/


All Articles