我创建了一个标签栏应用程序,我想一直以纵向显示,除非在应用程序的一个视图控制器中使用 Web 视图全屏播放 youtube 视频。
我该怎么做??
在项目设置中,选择纵向、横向左侧和横向右侧设备方向。
在 TabBarController 类中,重写支持的接口方向方法。请参阅下面的代码。将此代码复制并粘贴到您的 TabBar 控制器中
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
这可确保选项卡栏视图始终保持纵向。
在具有 Web 视图的 ViewController 中,实现以下版本的支持的 InterFaceOrientation 方法。
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;
}
这可确保具有 Web 视图的视图控制器可以更改为横向。
注意:以模式方式呈现具有 Web 视图的视图控制器。它不应该是 TabBar Controller 中的选项卡。