自动调整大小遮罩在 iOS 中何时生效?
我有一个笔尖,最初是为 iPhone 应用程序创建的,尺寸为 320x480,并设置了自动调整大小蒙版,以便在其超级视图很大时在各个方向上扩展视图。
我现在正在使我的应用程序变得通用,并使用相同的笔尖并将其显示在 iPad 上的页面表中。
我的问题是我根据帧大小进行了一些计算,但帧大小仍然显示为 320x480。但在其他方法中,框架尺寸正确显示为页面尺寸。
问题:自动调整大小蒙版何时生效,以便我可以在正确的时间进行计算?
I have a nib that I originally created for an iPhone app with dimensions 320x480 and with autoresizing masks set up to expand the view in every direction should its superview be large.
I am now making my app universal, and am using the same nib and showing it in a page sheet on the iPad.
My problem is that I make some calculations based on the frame size, which is still showing 320x480. But in other methods, the frame size is showing correctly as the size of the page sheet.
Question: When do the autoresizing masks take effect so I can make my calculations at the correct time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
autoresizingMask
属性在其超级视图的框架发生更改时生效。超级视图属性reizesSubviews
必须为 YES。当您加载 NIB 时,超级视图的框架将按照 NIB 中的方式进行设置。您可以在初始化时将其设置为您想要的任何值。The
autoresizingMask
property takes effect when the frame of it's superview changes. The superview propertyresizesSubviews
must be YES. When you load your NIB, the superview's frame is set as in the NIB. You can set this to whatever you want while initializing.我已经很长时间没有为 iOS 做过开发了,但我记得当设备旋转发生变化时旋转视图很重要。因此,当您设置将启用所有设备方向的视图控制器时,它将设置其视图的框架。该视图将依次设置所有子视图的框架。它将查看自动调整大小蒙版以检查它如何更改框架。
我对此不太确定,但我认为是这样的。测试一下并告诉我们!
IEF2
It has been a long time since I've done something with development for the iOS, but I remember it mattered when rotating views when the device's rotation changes. So when you setup a view controller that will enable all device orientations, it will set the frame of it's view. That view will at his turn set all the subviews' frames. It'll look at the autoresizing mask to check how it has to alter the frame.
I'm not sure about this, but I thought it was something like this. Test it and let us know!
ief2