ios - Can I install Auto Layout constraints in views that are owned by VCs outside of my control? -
I am new to auto-layout. I want to convert an existing project into auto layout. The project does not use the interface builder, the entire view hierarchy is programmatically set.
After reading and experimenting with Apple, I am still not clear whether I am allowed to install obstacles in thoughts or not No Do my own custom views Is one of the controllers? The question is particularly interesting in the case of predefined visual controller sections of the UIIC, but in reality can be extended for any third party's visual controller which is outside of my control. To illustrate my uncertainty, this example of the visual hierarchy: I am clearly responsible for the layout of SubViews Let's move upwards in the visual hierarchy again, since I want to use auto layout, I enable it on the subview, which is currently the view of Can anyone knowledgeable about auto layout provide some perceptual guidance to anyone here? What is one of the two solutions right above, which one, and why? Or am I somehow fundamentally confused? Your first instinct was correct; If it wants to use the automatic layout, then this will be set This means that if you want to create a custom container controller, then the container will have to set the property to
+ - UIWindow ----------------- ------------ ------ + | + - UINavigationController (?) ------------- + | | | + - MyViewController (UIView) ---------- + | | | | | + - ViewOn ------------------------ + | | | | | | | | | | | | | | + ----------------------------------- + | | | | | | + - View-to ------------------------ + | | | | | | | | | | | | | | + ----------------------------------- + | | | | | + --------------------------------------- + | | | + ------------------------------------------- + | + ----------------------------------------------- + < / code>
ViewOne and
ViewTwo . Since I want to use auto layout, I enable it by setting SubViews (by setting
translatesAutoresizingMaskIntoConstraints property to
NO of the subview), then I Installing> View of MyViewController
MyViewController (by setting
translatesAutoresizingMaskIntoConstraints property to
setting) ). But what should I do about the obstacles?
UINavigationController ? It feels strongly like I am violating the encapsulation of the
UINavigationController . Since I do not have any information about the internal view hierarchy of
UINavigationController , what is the method of setting a restriction that is not messing up
UINavigationController view layout? And what scene should I install, because I do not know the internal scene hierarchy?
Install any obstacles in the view of UIVAC controller ? At first glance, it seems to be the right thing to do, because now I am not violating the encapsulation - I leave it to
UINavigationController how it wants to get my idea and what obstacles Wants to set it up yourself However, my experiments clearly indicate that the correct solution is not because
UINavigationController never establishes any obstacles in itself - resulting in the result of
MyViewController Can get zero size frame
MyViewController view
UINavigationController < / code> is a container view controller, it takes a view controller and determines how to put a view of the baby controller. If you are using springs and struts or auto layout, then you should not care.
translatesAutoResizingMaskIntoConstraints to
not .
MyViewController that part should not be done. Open the source of an auto-layout enabled storyboard that should be set to the top-level view (people who directly view the view controller back) that property should be set to
NO , and you will see the top-level view < code> YES (while others do all other views).
NO and install any constraints. The custom container manages its view (which includes
MyViewController in this case), and is responsible for laying down its subviews.
Comments
Post a Comment