且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

肖像视频到风景

更新时间:2023-02-01 17:33:01

在视图控制器.m文件中,您应该

In your view controller .m file, you should have

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

在那里你可以返回 YES 对于支持的方向,这将使您能够旋转视频。

There you can return YES for supported orientations, which will enable you to rotate video.

如果你使用UINavigationController,这个方法也不行,除非所有视图都由 UINavigationController 实现 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 以同样的方式。

Also not that if you use UINavigationController, this aproach wont work, unless all views managed by UINavigationController implement - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation the same way.

同样在你的目标 - >你的项目 - >摘要中,你可以设置支持的方向。

Also in your Targets -> "You Project" -> Summary, you can set supported orientations.

编辑:
go 此处查看UIInterfaceOrientation。那里有你需要的常数。

go here an look for UIInterfaceOrientation. There you have constants you need.

我会这样写:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (interfaceOrientation == UIInterfaceOrientationPortrait)
       return YES;  
    if (interfaceOrientation == UIInterfaceOrientationLandscapeRight)
       return YES; 
    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
       return YES;
}