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". ...
随机推荐
- 如果你的eclipse在每次run或debug时都莫名其妙的做一件事
新项目,使用Ant打war包.结果写完了Ant以后,包是打好了,却使eclipse以后每次run或debug时都莫名其妙地自动先执行这个Ant, 让人十分苦恼. 其实,是你的eclipse设置出了问题 ...
- 什么是REST设计风格
https://zh.wikipedia.org/wiki/REST http://www.infoq.com/cn/articles/rest-introduction
- 企业IT管理说:全自动就一定是最好的吗?
现如今,企业基础设施变得越来越网络化.虚拟化并且愈加复杂,人们更愿意寻求自动化以期优化信息管理过程.毕竟,有谁不想要一个更为有效且迅速的法子来管控数据的安全.存储.应用性能监控以及IT的经济性?这不用 ...
- python内存泄漏,python垃圾手动回收,1
部署的舆情系统,内存变大,找原因. 一个小例子. def func(): local_list = list(range(10000000)) func() time.sleep(200) 能够观察到 ...
- Postman模拟Request Payload发送请求
Postman模拟Request Payload发送请求,如下图所示:
- Jackson Gson Json.simple 比较
为公司做了小任务,需要用到Java Json库,Json库我几个月之前就用过,不过那时候是跟着项目来的,延续了项目的使用习惯直接用了jackson Json,而这次我觉得好好比较一下几个常见的Json ...
- 标签a点击以后,5秒内禁止点击,5秒后激活
方法1:利用bootstrap里面的类disabled,禁止链接 <a href='javascript:onHref()' id="test">点击</a> ...
- python commands模块在python3.x被subprocess取代
subprocess 可以执行shell命令的相关模块和函数有: os.systemos.spawnos.popen --废弃popen2.* --废弃commands.* --废弃,3.x中被移除 ...
- SpringBoot(三)-- 整合FreeMarker模板
1.pom依赖 <!-- 引入freeMarker的依赖包. --> <dependency> <groupId>org.springframework.boot& ...
- [转]linux下释放文件内存
在Linux系统下,我们一般不需要去释放内存,因为系统已经将内存管理的很好.但是凡事也有例外,有的时候内存会被缓存占用掉,导致系统使用SWAP空间影响性能,此时就需要执行释放内存(清理缓存)的操作了. ...