When do autoresizing masks take effect in iOS?

≡放荡痞女 提交于 2019-12-10 15:13:57

问题


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?


回答1:


The autoresizingMask property takes effect when the frame of it's superview changes. The superview property resizesSubviews 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.




回答2:


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



来源:https://stackoverflow.com/questions/5736778/when-do-autoresizing-masks-take-effect-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!