像往常一样我有一个UIViewController的子类。当我加载应用程序时,我需要调整一些必须以编程方式放置的元素。当然,大小取决于接口方向:所以,我所做的:UIViewController interfaceOrientation问题
- (void)viewDidLoad {
switch([self interfaceOrientation]) {
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
NSLog(@"Portrait");
break:
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
NSLog(@"Landscape");
break;
}
但是,没有模拟器/设备的方向的事情,情况总是肖像在viewDidLoad中/ WillAppear,即使一切正常旋转。 在Plist中,我添加了所有支持的方向。 提示?
碰到完全相同的问题!这在模拟器中一直是个问题。 最好的是:打破“willRotate”,它告诉你它会旋转到风景。接下来它在layoutSubview中打破。如果你检查那里的方向,它是肖像! WTF? – Krumelur 2011-11-03 20:44:13
难道你应该重写'shouldAutorotateToInterfaceOrientation'并返回YES吗?如果你这样做,把你的代码移到那个方法。 – Mazyod 2012-05-19 04:55:44