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;
}
iOS - 视频播放处理全屏/横屏时候遇见的坑的更多相关文章
- H5视频播放自动全屏,暂停退出全屏等功能
html5视频播放自动全屏,暂停退出全屏等功能 在参考了html5 video fullScreen全屏实现方式及司徒正美的书<javascript框架设计>287页相关代码后,在Safa ...
- JS 取消iOS播放自动全屏:
iOS下浏览器模式下h5播放器强制是全屏的,除非在app下才可以非全屏播放,需要两个配置: (1)播放器添加参数: playsinline:true(我使用的是阿里云的播放器,其他的需要自己找找是那个 ...
- iOS任何界面全屏炫酷倒计时,一句代码就够了
概述 iOS全屏炫酷倒计时,任何界面只需要调用一句代码就能实现,支持定制倒计时数字.倒计时结束时显示的文本.支持倒计时播放图片.开始倒计时和结束倒计时的block和delegate回调.支持定制文本颜 ...
- C# 后台按键 视频播放器 全屏后无法 触发
第一种 (全屏不可触发) protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Win ...
- HTML5新标签video在iOS上默认全屏播放
今天做一个app时发现一个问题,应用html5中的video标签加载视频,在Android手机上默认播放大小,但是换成iPhone手机上出问题了,默认弹出全屏播放,查找了好多论坛,都没有谈论这个的.然 ...
- ios滑动手势全屏(这段代码实现了下一级控制器滑到上一级控制器)
在自定义导航控制器里面加以下代码就增加全屏滑动手势 >推向前一个控制器 // HBNavigationController.m // #import "HBNavigationCon ...
- html-----vedio标签(HTML5新标签VIDEO在IOS上默认全屏播放)
今天做一个app时发现一个问题,应用html5中的video标签加载视频,在Android手机上默认播放大小,但是换成iPhone手机上出问题了,默认弹出全屏播放,查找了好多论坛,都没有谈论这个的.然 ...
- video 安卓ios系统 浏览器 全屏播放以及自动播放的问题
ios自动播放 <body onload="load()"> <div class="result_box"> <div clas ...
- Android:webView加载h5网页视频,播放不了,以及横屏全屏的问题和实现自定义加载进度条的效果
1.webView加载h5网页视频,播放不了,android3.0之后要在menifest添加硬件加速的属性 android:hardwareAccelerated="true". ...
随机推荐
- 8 map的用法
what's map go里面的map和python字典差不多. 类似其他语言中的哈希表或者字典,以key-value的形式存储的数据 key必须是支持==或者!=比较运算的类型,不可以是函数.map ...
- 如何在Datatable中取得每列的数据列宽度
你用SqlDataAdapter填充DataTable的时候不要用Fill方法而应该用FillSchema方法: using (SqlConnection conn = new SqlConnecti ...
- PHP对HTML代码尸体编码2个函数
1.htmlspecialchars() 函数把一些预定义的字符转换为 HTML 实体. 2.htmlentities() 函数把字符转换为 HTML 实体. 记录下
- WebSocket、Socket、TCP、HTTP区别
https://www.cnblogs.com/merray/p/7918977.html
- Dubbo调用链(version:2.5.3)
Consumer 调用 Provider的过程: (CONSUMER)Dubbo服务调用处 --> 调用RPC代理 --> InvokerInvocationHandler#invoke( ...
- Android学习——在Android中使用OpenCV的第一个程序
刚開始学习Android,因为之前比較熟悉OpenCV,于是就想先在Android上执行OpenCV试试 =============================================== ...
- ZooKeeper 未授权访问漏洞
ZooKeeper 安装: Zookeeper的默认开放端口是2181 wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zooke ...
- C#编码习惯谈
1. 避免将多个类放在一个文件里面.2. 一个文件应该只有一个命名空间,避免将多个命名空间放在同一个文件里面.3. 一个文件最好不要超过500行的代码(不包括机器产生的代码).4. 一个方法的 ...
- Android学习之BitMap用法实例
下面简单说明了BitMap的用法: 从服务器下载一张图片,显示在ImageView控件上,并将该图片保存在移动设备的SD上. // 根据网络URL获取输入流 public InputStream ge ...
- java上传并压缩图片(等比例压缩或者原尺寸压缩)
本文转载自http://www.voidcn.com/article/p-npjxrbxr-kd.html 先看效果: 原图:1.33M 处理后:27.4kb 关键代码; package codeGe ...