xcode iOS中自动布局和自动调整大小的基本区别是什么

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25563128/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:27:06  来源:igfitidea点击:

What is the basic difference between Auto Layout and Auto Resizing in iOS

iosxcodeuser-interfaceautoresizeios-autolayout

提问by Arvind

I have been searching the proper difference between Auto Layout and Auto Resizing, but didn't able to find the exact answer. Where I can use "Auto Layout" and where "Auto Resizing" in app? Any help would be a part of thanks.

我一直在寻找 Auto Layout 和 Auto Resizing 之间的正确区别,但找不到确切的答案。我可以在哪里使用“自动布局”和应用程序中的“自动调整大小”?任何帮助都是感谢的一部分。

采纳答案by Santosh Sharma

As Matt Neuburg states in his book:

正如马特·诺伊堡 (Matt Neuburg) 在他的书中所说:

Autoresizing is a matter of conceptually assigning a subview “springs and struts.” A spring can stretch; a strut can't. Springs and struts can be assigned internally or externally. Thus you can specify (using internal springs and struts) whether and how the view can be resized, and (using external springs and struts) whether and how the view can be repositioned.

自动调整大小是在概念上分配子视图“弹簧和支柱”的问题。弹簧可以伸展;支柱不能。弹簧和支柱可以在内部或外部分配。因此,您可以指定(使用内部弹簧和支柱)是否以及如何调整视图的大小,以及(使用外部弹簧和支柱)是否以及如何重新定位视图。

And

Autolayout, depends on the constraints of views. A constraint (an instance of NSLayoutConstraint) is much more sophisticated than the "autoresizingMask" it's a full-fledged object with numeric values, and can describe a relationship between any two views (not just a subview and its superview).

自动布局,取决于视图的约束。约束(NSLayoutConstraint 的一个实例)比“autoresizingMask”复杂得多,它是一个具有数值的成熟对象,并且可以描述任何两个视图(不仅仅是子视图及其超视图)之间的关系。

回答by Santosh Sharma

I recommend watching the WWDC 2012 session https://developer.apple.com/videos/wwdc/2012/?id=202

我建议观看 WWDC 2012 会议https://developer.apple.com/videos/wwdc/2012/?id=202

Auto Layout is a new way to define dynamic GUIs. Before, we had autoresizing masks, that described how a subview will resize or move when its superview is resized. With Auto Layout you can do the same and also a lot more complicated GUIs quite easily.

自动布局是一种定义动态 GUI 的新方法。之前,我们有自动调整大小蒙版,它描述了子视图在其父视图调整大小时如何调整大小或移动。使用自动布局,您可以很容易地做同样的事情,也可以做更复杂的 GUI。

Autoresizing is one of the most useful property for layouting the views in their hierarchies. go through this link.

自动调整大小是在其层次结构中布局视图的最有用的属性之一。通过这个链接。

http://www.techpaa.com/2012/05/understanding-uiview-autoresizing.html

http://www.techpaa.com/2012/05/understanding-uiview-autoresizing.html

回答by Rabindra Nath Nandi

AutoResizing :Autoresizing means that how the content of a view will fit to the view. It probably depends on the self content of the view.

AutoResizing :Autoresizing 意味着视图的内容将如何适应视图。这可能取决于视图的自身内容。

AutoLayout:AutoLayout means how the external constraints like the position of the view , the size of view supported by the other neighboring components.

AutoLayout:AutoLayout 是指视图的位置、其他相邻组件支持的视图大小等外部约束。

AutoLayout triggers the AutoResizing Task and for autoresizing activity , auto-layout forcefully or normally change or break the default constraints of views which are related to the corresponding view if needed.

AutoLayout 触发 AutoResizing Task 和 autoresizing 活动,如果需要,自动布局强制或正常更改或打破与相应视图相关的视图的默认约束。

回答by yaksha

Use autolayout in the superview with constraints [this helps when there are changes in the space in the View due to different devices(such as 3.5 or 4 inches retina)] and use autoresize for resizing the GUI objects in a view [this helps when there are changes in the space in the View during the orientation of the device]

在带有约束的超级视图中使用自动布局[当视图中的空间因不同的设备(例如 3.5 或 4 英寸视网膜)而发生变化时这会有所帮助] 并使用自动调整大小来调整视图中的 GUI 对象的大小[这有助于当有是设备定位期间视图中空间的变化]