以编程方式自动调整掩码与 Interface Builder/xib/nib

Autoresizing masks programmatically vs Interface Builder / xib / nib(以编程方式自动调整掩码与 Interface Builder/xib/nib)

本文介绍了以编程方式自动调整掩码与 Interface Builder/xib/nib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个(可能是错误的)假设,即在 xib 中启用右边距指示器等同于在代码中使用 UIViewAutoresizingFlexibleLeftMargin 等等.

I was in an (probably false) assumption that enabling the right margin indicator in xib is equivalent to using UIViewAutoresizingFlexibleLeftMargin inside code and so on.

所以,我曾经根据这个快照思考:

So, I used to think according to this snapshot:

今天晚些时候,我不得不交叉检查,偶然发现 这个帖子.

Later today I had to cross check, and stumbled upon this thread.

还有苹果文档,标题为使用自动调整规则自动处理布局更改"的部分:https://developer.apple.com/library/content/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/CreatingViews/CreatingViews.html

And also the apple documentation, entitled with the section with title - "Handling Layout Changes Automatically Using Autoresizing Rules" in this link: https://developer.apple.com/library/content/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/CreatingViews/CreatingViews.html

所以我现在有了一个新的概念,即以编程方式设置自动调整大小掩码如何等同于 xib 设置:

So I now have a renewed concept in my mind as to how setting autoresizing masks programmatically would be equivalent to xib settings:

场景 1:仅设置 (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight) 相当于:

在 XIB 中?

场景 2:在代码中设置 (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin) 相当于:

Scenario 2: Setting (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin) in code is equivalent to:

在 XIB 中?

我的 2 个更新的场景是否正确?我现在在我的理解中吗?

Are my 2 renewed scenarios correct? Am I right now in my understanding?

推荐答案

是的,Interface Builder 在某种意义上把它颠倒了"(或者 UIView,取决于你如何看待它).您引用的场景"是正确的.

Yes, Interface Builder has it "reversed" in a sense (or UIView, depending on how you look at it). Your cited "scenarios" are correct.

这篇关于以编程方式自动调整掩码与 Interface Builder/xib/nib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:以编程方式自动调整掩码与 Interface Builder/xib/nib

基础教程推荐