【发布时间】:2016-01-12 09:46:48
【问题描述】:
我已使用以下代码在子视图控制器中将方向从纵向更改为横向
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
但是当我转到后台并返回前台时,我按下按钮转到主页然后需要使用以下代码将方向从横向更改为纵向
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if ([ConfigObjC currentPage] && [[ConfigObjC currentPage] isEqualToString:@"SubViewController"])
{
return UIInterfaceOrientationMaskLandscapeLeft;
}
else{
return UIInterfaceOrientationMaskPortrait;
}
}
但它不起作用。
当我不去背景时,我已经成功地将方向从横向更改为纵向。怎么解决这个问题非常感谢
【问题讨论】:
标签: ios screen orientation screen-orientation