search

Home  >  Q&A  >  body text

objective-c - ios 其它的VC中都不横屏 只有一个VC横屏 该如何实现 百度了很多种方法 都不行

是这样的 我只想专门做一个可以横屏播放视频的controller 有人知道怎么弄吗 我已经写好代码 只有横屏没实现了 如果可以 你可以运行一下我的代码 我把.h .m发给你,实现横屏 不要说把project里面的landspace 勾选 我只想用代码控制横屏 谢谢

PHPzPHPz2887 days ago262

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 17:36:58

    This question is quite similar to https://segmentfault.com/q/1010000004486783/a-1020000004487227. I moved my answer here:

    Add the shouldAutorotate method in ViewController. The logic inside is roughly as follows:

    @implementation ViewController
    - (BOOL)shouldAutorotate {
        int32_t i = 1;
        if (i == 1) {
            return NO;
        }
        return YES;
    }
    @end

    If your ViewController is managed in UINavigationController, you need to modify the corresponding behavior of UINavigationController. For example, the implementation idea through Category is roughly as follows:

    #import "UINavigationController.h"
    @implementation UINavigationController (Overrides)
    - (BOOL)shouldAutorotate {
        id currentViewController = self.topViewController;
        if ([currentViewController isKindOfClass:[<#your-vc#> class]]) {
            int32_t i = 1; 
            if (i == 1) {
                return NO;
            }
            return YES;
        }
        return YES;
    }
    @end

    reply
    0
  • 阿神

    阿神2017-04-17 17:36:58

    See if this helps you: http://www.tekuba.net/program/306/

    reply
    0
  • Cancelreply