因此,为了处理方向变化(从某种观点看,不是控制者),我们在UIDeviceOrientationDidChange通知中登记。 所有这一切都是好的。
It gets called on app startup, reporting the correct dimensions but incorrectly saying something changed (due to having landscape views or other software-reasons this may be triggered).
在少数不必要信息之后,它将开始发出合法信息。 该装置将报告正确的“取向”,但它仍然给出目前框架(和约束)无效。
To scroll the page to the right, other SO questions lead me to remember to manually set the contentOffset, which has most of what I need. currentPage = current Y offset / width of scrollview. Basic math, cool.
这确定了我的大部分问题。 就适当的业务协调办公室而言,我对一项延期职能表示意见,而这一职能恰恰是“iPad”的大小,因为“iPad”是一个表层,我这样做:
float currentDeviceWidth = 768;
float currentHeight = 949; //logging the frame from portrait, landscape = 1024 w, 693 h
UIDeviceOrientation o = [[UIDevice currentDevice] orientation];
if (!UIDeviceOrientationIsPortrait(o)) {
//landscape
currentDeviceWidth = 1024;
currentHeight = 693;
}
else
NSLog(@"Moving to port, unless on startup, then its staying as");
Which handles the orientationDidChange: messages, but when the app starts, the scroll view is now smaller than it should be because it set its size as if the bounds it s getting are "about to change", when they re not.
Possible solutions: a) [self performSelector:@selector(relayout) withObject:nil afterDelay:delayNum];
b) 在确定“BOOL dontIgnoreLayout”之前,给予一定时间的拖延。
c) Find another way to test for orientation
d) 手工操作,发现最初发送的所有信息,消除所有原因,只有在该系统没有设立时,这一选择才有可能。 我可以用一个新项目来检验,尽管它掌握了企业情况,但如果是这样的话,它可能还会有点窃取。
Wondering if anyone solved this. If not, I have to put in "special case" or "time based" code, neither of which are OO style, at least not my preferred way (nor my coworkers).
如果我错过了有关SO的内容,让我知道,但正如你能够看到的那样,我迄今找到了一些答案。
Thanks