iPhone 横竖屏切换,全屏播放的三种方式
1. 调用系统自带的强制屏幕旋转不过还得在AppDelegate中重写下面方法
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
// 0:竖屏,1:单向横屏,2:双向横屏
if (self.httpConnect.SupportedOrientation==) {
return UIInterfaceOrientationMaskPortrait;
}
else if (self.httpConnect.SupportedOrientation==){
return UIInterfaceOrientationMaskLandscapeRight;
}
else{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
}
在Viewcontroller中添加下面方法
-(BOOL)shouldAutorotate
{
return NO;
}
- (void)hideNavigationAndTabBar:(BOOL)state {
[self.navigationController.navigationBar setHidden: state];
[self.tabBarController.tabBar setHidden: state];
[[UIApplication sharedApplication] setStatusBarHidden:state];
}
- (void)gotoFullScreenMode {
self.movieView.frame = CGRectMake(, , SCREEN_HEIGHT, SCREEN_WIDTH);
[self hideNavigationAndTabBar:YES];
self.httpConnect.SupportedOrientation = ;
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeRight] forKey:@"orientation"];
}
- (void)backToPortraitMode {
[UIView animateWithDuration:0.2 animations:^{
self.httpConnect.SupportedOrientation = ;
[self hideNavigationAndTabBar:NO];
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];
} completion:nil];
}
2. 全屏播放利用[UIApplication sharedApplication].keyWindow,主要代码如下
//不过这种方式麻烦一点,全屏时把movieView从self.view中移到keyWindow当中去;退回全屏时又得把movieView从keyWindow中加到movieView中去,还得重新考虑布局,不推荐这种方式;
iOS8 之后 [UIScreen bounds] 的宽高会随屏幕方向改变
- [UIScreen bounds] now interface-oriented
- [UIScreen applicationFrame] now interface-oriented
#define AppKeyWindow ([UIApplication sharedApplication].keyWindow)
- (void) gotoPlayVideoInFullScreen { [[UIApplication sharedApplication]setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade]; [AppKeyWindow addSubview: self.movieView];
self.movieView.transform = CGAffineTransformMakeRotation(M_PI_2);
self.movieView.frame = CGRectMake(, , SCREEN_WIDTH, SCREEN_HEIGHT);
} - (void)backToNormalState { [[UIApplication sharedApplication]setStatusBarHidden:NO withAnimation: UIStatusBarAnimationSlide];
self.movieView.transform = CGAffineTransformIdentity;
[self.movieView removeFromSuperview]; [self.view addSubview:self.movieView];
}
3. 第三种最方便快捷的,直接对self.view进行动画旋转,代码如下
- (void)gotoPlayVideoInLandscapeMode{
[self hideNavigationAndTabBar:YES];
self.view.transform = CGAffineTransformMakeRotation(M_PI/);
CGRect frame = [UIScreen mainScreen].applicationFrame;
self.view.bounds = CGRectMake(, , frame.size.height, frame.size.width);
}
- (void)gotoPlayVideoInPortraitMode {
self.view.transform = CGAffineTransformIdentity;
[self hideNavigationAndTabBar:NO];
[self.view layoutIfNeeded];
}
- (void)hideNavigationAndTabBar:(BOOL)state {
[self.navigationController.navigationBar setHidden: state];
[self.tabBarController.tabBar setHidden: state];
[[UIApplication sharedApplication] setStatusBarHidden:state];
}
iPhone 横竖屏切换,全屏播放的三种方式的更多相关文章
- js 切换全屏
公司有一个需求就是点击某一个按钮实现全屏切换功能,然后呢我就在网上扒了段代码.封装了一下.使用的小伙伴们可以看看哦! 切换全屏代码 <!DOCTYPE html> <html> ...
- OSG addEventHandler W键显示网格 L键控制光照 F键切换全屏窗口 S键显示统计数据 事件处理器
#include <osgGA/StateSetManipulator> #include <osgViewer/ViewerEventHandlers> // add the ...
- js之切换全屏和退出全屏实现
应用场景:比如很多网页游戏全屏之类的,或者是网上看小说等. 核心代码: //控制全屏 function enterfullscreen() { //进入全屏 $("#fullscreen&q ...
- IOS(苹果手机)使用video播放HLS流,实现在内部播放及全屏播放(即非全屏和全屏播放)。
需求: 实现PC及移动端播放HLS流,并且可以自动播放,在页面内部播放及全屏播放功能. 初步:PC及安卓机使用hls.js实现hls流自动播放及全屏非全屏播放 首先使用了hls.js插件,可以实现在P ...
- HTML页面全屏/退出全屏
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- putty字体大小颜色、全屏/退出全屏快捷键 保存session设置[转]
字体大小设置 Window->Appearance->Font settings->Change按钮设置(我的设置为16)字体为(Consolas) 字体颜色设置 Window-&g ...
- 【百度地图API】关于如何进行城市切换的三种方式
原文:[百度地图API]关于如何进行城市切换的三种方式 摘要:本文介绍了三种切换城市的方式:查询城市.城市列表和显示城市轮廓. ------------------------------------ ...
- android 播放视频时切换全屏隐藏状态栏
1. Demo: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstance ...
- iPhone新建项目不能全屏
上个周做项目的时候,发现新建了一个项目不能全屏.伤透了我的脑筋,然后又请教了团队里其他两个大牛帮我搞定了这个问题. 虽然是搞定了,但也看的出大牛也是云里雾里.歪打正着解决的. 今天又想新做个项目,这个 ...
随机推荐
- 实例解析Docker数据卷+数据卷容器+flocker数据共享+DockerHub操作
Docker内部数据管理和Docker之间的数据共享为数据卷和数据卷容器,实例解析1.将本地的文件作为容器的数据卷,2.数据卷flocker插件实现容器集群(或者Docker Swarm)的数据共享3 ...
- CentOS 7 下 安装Webmin 启动防火墙失败----Applying firewall rules:iptables-restore:line 2 failed
最近学习CentOS 7 系统管理,使用的是<CentOS 6.X系统管理实战宝典>一书------因为网购的CentOS 7 的书还没有送到 O(‘ ’!!)O~ (1)先使用yum方 ...
- 形象解释C#、Net、Asp.net
下文是写给计算机小白的,尽量用形象的语言来让她们明白这些比较抽象的概念. -------------------------------------- C#: 你和美国人说话要说英语 和中国人说话说汉 ...
- Linq中的in和not in的使用方法
T-SQL语句: select * from PayingRecords where ClientID='17787665-1d98-49e6-b254-a6a6553c4b42' and ID no ...
- layui 设计资源——2.0 版本的 Axure 组件包,产品交互设计利器
大家好,很久不见,这次为大家分享的是 layui_2.0版本的axure组件包,在去年发布的 layui Axure 1.0 中(见:http://fly.layui.com/jie/9842/ )赢 ...
- docker images存放路径指定
steps: 1. mkdir /home/docker(你想要docker存放image的目录) 2. systemctl stop docker 3. vi /usr/lib/systemd/sy ...
- calculate fraction by oracle
QUESTION:When you meet calculate fraction in oracle SOLUTION: 1.Check out their values respectively. ...
- css z-index层重叠顺序
一.z-index语法与结构 z-index 跟具体数字 如:div{z-index:100}注意:z-index的数值不跟单位. z-index的数字越高越靠前,并且值必须为整数和正数(正数的整数) ...
- maven仓库使用HTTP代理,maven仓库使用本地jar
setting.xml <proxies> <proxy> <id>proxy</id> <active>true</active&g ...
- linux-记录
查看运行的进程 ps -aux|grep java 找到要删除的进程的编号 杀死进程 kill -9 1883(进程编号) 重启服务 sh satrtBussinessService.sh