Autoresizing masks programmatically vs 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
基础教程推荐
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01