WEB开发网
开发学院手机开发iPhone 开发 修正iOS6上Oritentation的问题 阅读

修正iOS6上Oritentation的问题

 2012-10-08 13:42:57 来源:WEB开发网   
核心提示: 1.将addSubview修改为setRootViewController[window addSubview: viewController.view];修改如下:if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0){// warnin

 1.将addSubview修改为setRootViewController

[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];
}
2.修改shouldAutorotateToInterfaceOrientation

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape( interfaceOrientation );
}

iOS6以前会呼叫这方法来判断手机是垂直或打横

// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead of shouldAutorotateToInterfaceOrientation
- (NSUInteger) supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}

- (BOOL) shouldAutorotate {
return YES;
}

Tags:修正 iOS Oritentation

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接