Mon*_*tel 5 landscape objective-c uiinterfaceorientation ios
我希望在全屏模式下以横向模式播放视频.我的应用程序锁定在纵向模式.如何实现这一点.请帮我.提前致谢
swift中最简单的解决方案3将此添加到您的应用代理:
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
if window == self.window {
return .portrait
} else {
return .allButUpsideDown
}
}
Run Code Online (Sandbox Code Playgroud)
我已经在我的应用程序中完成了此操作。为此,您需要检查您想要播放视频的视图控制器。
您要做的第一件事是在项目目标中检查“设备方向”为“纵向”、“横向左”、“横向右”
在您的 AppDelegate 中执行以下代码
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
UIStoryboard *mainStoryboard;
if (IS_IPHONE) {
mainStoryboard= [UIStoryboard storyboardWithName:@"Main" bundle: nil];
}
else{
mainStoryboard= [UIStoryboard storyboardWithName:@"Main_iPad" bundle: nil];
}
ViewControllerThatPlaysVideo *currentViewController= ViewControllerThatPlaysVideo*)[mainStoryboard instantiateViewControllerWithIdentifier:@"postDetailView"];
if(navigationController.visibleViewController isKindOfClass: [ViewControllerThatPlaysVideo class]]){
if([currentViewController playerState])
return UIInterfaceOrientationMaskLandscape|UIInterfaceOrientationMaskPortrait;
return UIInterfaceOrientationMaskPortrait;
}
return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
5045 次 |
| 最近记录: |