我目前正在构建一个 iOS 应用程序,唯一支持的方向是左右横向。我已经通过几种方式指定了这一点:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation); //iOS 5 compatibility.
}
-(NSInteger)supportedInterfaceOrientations:(UIWindow *)window{
    return UIInterfaceOrientationMaskLandscape; //iOS 6
}
-(BOOL)shouldAutorotate{
    return YES;
}
而且我已经在应用程序的 Info.plist 中将支持的方向指定为仅横向的方向。当我在我的设备上(甚至在模拟器中)运行应用程序时,我知道根视图是横向的(切换器位于屏幕的长边,通知中心也是如此),但是内容仍然来自屏幕的左上角,就像在纵向模式下一样,而不是左下角或右上角,就像我想要的那样。我不知道是什么导致内容不随父视图旋转,因为此代码适用于 iOS 5,但不适用于 iOS 6。
编辑:这是一个截图。
编辑:这是我的 main.m:
#import <UIKit/UIKit.h>
int main(int argc, char **argv) {
    NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init];
    int ret = UIApplicationMain(argc, argv, @"ClockApplication", @"ClockApplication");
    [p drain];
    return ret;
}
这是我的 ClockApplication.mm:
#import "RootViewController.h"
@interface ClockApplication: UIApplication <UIApplicationDelegate> {
    UIWindow *_window;
    RootViewController *_viewController;
}
@property (nonatomic, retain) UIWindow *window;
@end
@implementation ClockApplication
@synthesize window = _window;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
    _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    _viewController = [[RootViewController alloc] init];
    [_window addSubview:_viewController.view];
    [_window makeKeyAndVisible];
}
- (void)dealloc {
    [_viewController release];
    [_window release];
    [super dealloc];
}
@end