iOS仅肖像应用程序从横向UIWebview youtube返回

Joh*_*an_ 5 youtube uiwebview ios landscape-portrait

我正在创建一个iOS application,我遇到了以下问题:

该项目设置为portrait模式应用程序.我有一个UIWebview,它加载一个带有youtube视频的网页.单击视频时,它将从中开始youtube player.当视频更改为landscape模式并单击"完成"时,它将返回UIWebview显示的状态landscape.

NSNotification视频完成后我确实收到了一个但是我无法强制portrait模式.

这应该是不可能的,我如何允许youtube进入landscape但强制应用程序保持portrait模式?或者还有另一种解决方法吗?

编辑:

在与Apple联系之后,它被证明是一个错误并被报道.

Sha*_*lam 0

我认为你可以像你说的那样使用 NSNotification 并在调用的方法中使用这行代码现在强制视图为纵向

- (void)YourMethodCalledByNSNotification
{
    UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;

    if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight || orientation == UIInterfaceOrientationPortraitUpsideDown) 
    {
        [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
    }
}
Run Code Online (Sandbox Code Playgroud)

希望有帮助