ios 横屏的时候显示固定的 vc(视图)

手机横屏固定显示某个页面

手机 app 开启横屏, 横屏的时候, 手机显示固定的页面, 无论app 在哪一个页面横屏显示的始终是某个页面

 

方法:1app

-(BOOL)shouldAutorotate{ide

return YES;server

}it

- (NSUInteger)supportedInterfaceOrientationsio

{object

return UIInterfaceOrientationMaskAll;select

}方法

注意该方法要写在控制器的根视图里才生效notification

2.通知: (要想在哪一个页面都实现这种方法写在 APPdelegate 里)view

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarOrientationChange:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];

- (void)statusBarOrientationChange:(NSNotification *)notification{  UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

//在这个位置建立 view 或者 VC

if (orientation == UIInterfaceOrientationLandscapeRight) // home键靠右

{

//将 vc 或者 view 加到 window 上

}

if (orientation ==UIInterfaceOrientationLandscapeLeft) // home键靠左

{

//将 vc 或者 view 加到 window 上

}

if (orientation == UIInterfaceOrientationPortrait)

{

//将 vc 或者 view 从 window 上删除

}

if (orientation == UIInterfaceOrientationPortraitUpsideDown)

{

//将 vc 或者 view 从 window 上删除

}

}

相关文章
相关标签/搜索