• iOS


       视频播放想要全屏,使用shouldAutorotate方法禁止主界面,tabbar控制器横屏,导致push进入播放页面不能横屏的问题。。。

    - (BOOL)shouldAutorotate {
    
        return NO;
    
    }
    
     
    
    - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    
        return UIInterfaceOrientationMaskAll;
    
    }
    
     
    
    后面解决方法:
    
    - (void)fullScreenClick:(UIButton *)sender {
    
        sender.selected = !sender.selected;
    
        if (sender.isSelected) {
    
            _backButton.hidden = YES;
    
            [self forceOrientationLandscapeLeft];
    
        } else {
    
            _backButton.hidden = NO;
    
            [self forceOrientationPortrait];
    
        }
    
    }
    
     
    
    //MARK: -- 强制横屏
    
    - (void)forceOrientationLandscapeLeft
    
    {
    
        AppDelegate *appdelegate=(AppDelegate *)[UIApplication sharedApplication].delegate;
    
        appdelegate.isForcePortrait=NO;
    
        appdelegate.isForceLandscape=YES;
    
        [appdelegate application:[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:self.view.window];
    
        
    
        YNCNavigationViewController *navi = (YNCNavigationViewController *)self.navigationController;
    
        navi.interfaceOrientation = UIInterfaceOrientationMaskLandscape;
    
        navi.interfaceOrientationMask = UIInterfaceOrientationMaskLandscape;
    
        
    
        //设置屏幕的转向为横屏
    
        [[UIDevice currentDevice] setValue:@(UIDeviceOrientationLandscapeLeft) forKey:@"orientation"];
    
        //刷新
    
        [UIViewController attemptRotationToDeviceOrientation];
    
    }
    
     
    
    //MARK: -- 强制竖屏
    
    - (void)forceOrientationPortrait
    
    {
    
        AppDelegate *appdelegate=(AppDelegate *)[UIApplication sharedApplication].delegate;
    
        appdelegate.isForcePortrait=YES;
    
        appdelegate.isForceLandscape=NO;
    
        [appdelegate application:[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:self.view.window];
    
        
    
        YNCNavigationViewController *navi = (YNCNavigationViewController *)self.navigationController;
    
        navi.interfaceOrientation = UIInterfaceOrientationPortrait;
    
        navi.interfaceOrientationMask = UIInterfaceOrientationMaskPortrait;
    
        
    
        //设置屏幕的转向为竖屏
    
        [[UIDevice currentDevice] setValue:@(UIDeviceOrientationPortrait) forKey:@"orientation"];
    
        //刷新
    
        [UIViewController attemptRotationToDeviceOrientation];
    
    }
    
     
    
    #import <UIKit/UIKit.h>
    
     
    
    @interface AppDelegate : UIResponder <UIApplicationDelegate>
    
     
    
    @property (strong, nonatomic) UIWindow *window;
    
     
    
    @property (assign , nonatomic) BOOL isForceLandscape;
    
    @property (assign , nonatomic) BOOL isForcePortrait;
    
     
    
    @end
    
    AppDelegate.m
    
    -(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
    
        if (self.isForceLandscape) {
    
            return UIInterfaceOrientationMaskLandscape;
    
        }else if (self.isForcePortrait){
    
            return UIInterfaceOrientationMaskPortrait;
    
        }
    
        return UIInterfaceOrientationMaskPortrait;
    
    }
    
     
    
    @interface YNCNavigationViewController : UINavigationController
    
     
    
    //旋转方向 默认竖屏
    
    @property (nonatomic , assign) UIInterfaceOrientation interfaceOrientation;
    
    @property (nonatomic , assign) UIInterfaceOrientationMask interfaceOrientationMask;
    
     
    
    @end
    
     
    
    .m
    
    #pragma mark - 由子控制器控制自己的转屏逻辑
    
    - (BOOL)shouldAutorotate {
    
        return YES;
    
    }
    
     
    
    - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    
        return self.interfaceOrientationMask;
    
    }
    
     
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    
        return self.interfaceOrientation;
    
    }
  • 相关阅读:
    C# 验证IP地址、Email格式、URl网址
    如何创建、安装和调试Windows服务
    C#发送Email邮件方法总结
    C#调用java类、jar包方法。
    未在本地计算机上注册“microsoft.ACE.oledb.12.0”提供程序
    在已经存在的表上创建索引
    Windows下的.NET+ Memcached安装
    把表从Access2007导出到Sql Server
    FusionCharts参数说明
    Sublime Text 3 之配置package control
  • 原文地址:https://www.cnblogs.com/gongyuhonglou/p/7058599.html
Copyright © 2020-2023  润新知