小编svt*_*vth的帖子

在全屏幕上强制横向方向MPMoviePlayerController在退出全屏时阻止正确旋转

我有一个支持所有界面方向的iPhone应用程序(iOS6 +).但是,当MPMoviePlayerController正在播放全屏视频时,应仅支持横向.

我在Stack Overflow上找到了以下解决方案,它可以工作.

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerWillEnterFullscreenNotification:) name:MPMoviePlayerWillEnterFullscreenNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerWillExitFullscreenNotification:) name:MPMoviePlayerWillExitFullscreenNotification object:nil];
Run Code Online (Sandbox Code Playgroud)

...

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    if (self.landscapeOnlyOrientation) {
        return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
    }
    return UIInterfaceOrientationMaskAll;
}

- (void)moviePlayerWillEnterFullscreenNotification:(NSNotification*)notification {
    self.landscapeOnlyOrientation = YES;
}

- (void)moviePlayerWillExitFullscreenNotification:(NSNotification*)notification {
    self.landscapeOnlyOrientation = NO;
}
Run Code Online (Sandbox Code Playgroud)

然而,一个恼人的问题仍然存在,即如果视频以纵向方向退出全屏(在强制风景中播放之后),则底层视图不会向后旋转.我必须手动将设备旋转到横向并返回到纵向以触发更新方向.有没有什么方法可以以编程方式触发这种更新?

以下一组截图应说明我的意思:

在此输入图像描述 在此输入图像描述 在此输入图像描述

注意:由于各种原因,无法使用MPMoviePlayerViewController.

iphone objective-c mpmovieplayercontroller uiinterfaceorientation ios

14
推荐指数
2
解决办法
1万
查看次数

如何使用python控制屏幕进程

我正在尝试拼凑一些Python代码来控制UNIX屏幕进程(/ usr/bin/screen),作为脚本的一部分,以简化服务器上​​的部署.是否有任何图书馆或模块可以促进这一点?有没有比使用标准Python子进程更好的方法呢?

python unix gnu-screen

6
推荐指数
1
解决办法
3536
查看次数