简体   繁体   English

什么时候自动调整大小的掩码在iOS中生效?

[英]When do autoresizing masks take effect in iOS?

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. 我有一个我最初为尺寸为320x480的iPhone应用程序创建的笔尖,并设置了自动调整遮罩,以便在其超级视图很大时向各个方向展开视图。

I am now making my app universal, and am using the same nib and showing it in a page sheet on the iPad. 我现在正在使我的应用程序通用,并且使用相同的笔尖并在iPad的页面表格中显示它。

My problem is that I make some calculations based on the frame size, which is still showing 320x480. 我的问题是我根据帧大小进行了一些计算,帧大小仍然显示为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? 问题:自动调整遮罩何时生效,以便我可以在正确的时间进行计算?

The autoresizingMask property takes effect when the frame of it's superview changes. autoresizingMask属性在其autoresizingMask视图的帧发生更改时生效。 The superview property resizesSubviews must be YES. resizesSubviews属性resizesSubviews必须为YES。 When you load your NIB, the superview's frame is set as in the NIB. 加载NIB时,superview的帧设置为NIB。 You can set this to whatever you want while initializing. 您可以在初始化时将其设置为您想要的任何内容。

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. 自从我为iOS开发了一段时间以来,已经有很长一段时间了,但我记得在设备的旋转发生变化时旋转视图很重要。 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 ief2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM