天天看點

iOS6.0 xcode4.5 設定 橫屏

更新xcode4.5    iOS 6.0後以前的橫屏項目 變為了豎屏,以下為解決辦法:

在AppDelegate 的初始化方法

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions中
           

[window addSubview: viewController.view];
           

替換為下面代碼:

if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)

{ // warning: addSubView doesn't work on iOS6

[window addSubview: viewController.view];

}

else

{ // use this mehod on ios6

[window setRootViewController:viewController];

}
           

在RootViewController 中添加下面兩個方法 即可:

- (NSUInteger) supportedInterfaceOrientations{

return UIInterfaceOrientationMaskLandscape;

}

- (BOOL) shouldAutorotate {

return YES;
}