Autoresizing masks programmatically vs Interface Builder / xib / nib

10/14 00:50
阅读数 0

问题:

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. 我在(可能是错误的)假设中,在xib中启用右边距指示符等同于在代码中使用UIViewAutoresizingFlexibleLeftMargin等等。

So, I used to think according to this snapshot: 所以,我曾经根据这个快照思考: 在此输入图像描述

Later today I had to cross check, and stumbled upon this thread . 今天晚些时候我不得不交叉检查,偶然发现了这个帖子

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 还有苹果文档,标题为标题部分 - “使用自动调整规则自动处理布局更改”链接: https//developer.apple.com/library/content/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/CreatingViews/ CreatingViews.html

So I now have a renewed concept in my mind as to how setting autoresizing masks programmatically would be equivalent to xib settings: 所以我现在脑子里有一个更新的概念,关于如何以编程方式设置自动调整掩码等同于xib设置:

Scenario 1 : Setting only (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight) is equivalent to: 场景1 :仅设置(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)相当于:

(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)

In XIB? 在XIB?

Scenario 2 : Setting (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin) in code is equivalent to: 场景2 :代码中的设置(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin)相当于:

(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin)

In XIB? 在XIB?

Are my 2 renewed scenarios correct? 我的2个更新方案是否正确? Am I right now in my understanding? 我现在理解了吗?


解决方案:

参考一: https://en.stackoom.com/question/WXOF
参考二: https://stackoom.com/question/WXOF
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部