我像往常一样有一个 UIViewController 的子类。当我加载应用程序时,我需要调整一些我必须以编程方式放入的元素的大小。当然,大小取决于界面方向:所以,我做了:
- (void)viewDidLoad {
switch( [self interfaceOrientation] ) {
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
NSLog(@"Portrait");
break:
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
NSLog(@"Landscape");
break;
}
但无论模拟器/设备的方向如何,在 viewDidLoad/WillAppear 中的情况始终是 Portrait,即使一切都正确旋转。在 Plist 中,我添加了所有支持的方向。提示?