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 横竖屏切换,全屏播放的三种方式的更多相关文章

  1. js 切换全屏

    公司有一个需求就是点击某一个按钮实现全屏切换功能,然后呢我就在网上扒了段代码.封装了一下.使用的小伙伴们可以看看哦! 切换全屏代码 <!DOCTYPE html> <html> ...

  2. OSG addEventHandler W键显示网格 L键控制光照 F键切换全屏窗口 S键显示统计数据 事件处理器

    #include <osgGA/StateSetManipulator> #include <osgViewer/ViewerEventHandlers> // add the ...

  3. js之切换全屏和退出全屏实现

    应用场景:比如很多网页游戏全屏之类的,或者是网上看小说等. 核心代码: //控制全屏 function enterfullscreen() { //进入全屏 $("#fullscreen&q ...

  4. IOS(苹果手机)使用video播放HLS流,实现在内部播放及全屏播放(即非全屏和全屏播放)。

    需求: 实现PC及移动端播放HLS流,并且可以自动播放,在页面内部播放及全屏播放功能. 初步:PC及安卓机使用hls.js实现hls流自动播放及全屏非全屏播放 首先使用了hls.js插件,可以实现在P ...

  5. HTML页面全屏/退出全屏

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. putty字体大小颜色、全屏/退出全屏快捷键 保存session设置[转]

    字体大小设置 Window->Appearance->Font settings->Change按钮设置(我的设置为16)字体为(Consolas) 字体颜色设置 Window-&g ...

  7. 【百度地图API】关于如何进行城市切换的三种方式

    原文:[百度地图API]关于如何进行城市切换的三种方式 摘要:本文介绍了三种切换城市的方式:查询城市.城市列表和显示城市轮廓. ------------------------------------ ...

  8. android 播放视频时切换全屏隐藏状态栏

    1. Demo: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstance ...

  9. iPhone新建项目不能全屏

    上个周做项目的时候,发现新建了一个项目不能全屏.伤透了我的脑筋,然后又请教了团队里其他两个大牛帮我搞定了这个问题. 虽然是搞定了,但也看的出大牛也是云里雾里.歪打正着解决的. 今天又想新做个项目,这个 ...

随机推荐

  1. 判断sql是否存在特定的对象

    1 判断数据库是否存在if exists (select * from sys.databases where name = '数据库名') drop database [数据库名] 2 判断表是否存 ...

  2. 终止ajax请求

    在做搜索功能时,文本框输入文本就得请求一次数据,如果上一次的请求还没回又请求了就导致数据错误和无用的数据请求. 我们需要输入文本时候判断上一次的ajax请求是否完毕,若还没完毕就终止本次请求. 对于j ...

  3. Hadoop生态体系

    Hadoop路线 HDFS  分布式文件系统 MapReduce  分布式编程框架 ZooKeeper  分布式协调框架 Hive  非关系型数据仓库 Flume  日志采集框架

  4. 表单校验常用原生js库

    1.字符串去除左右空格继承形式// 除去左右空格String.prototype.Trim = function() { return this.replace(/(^\s*)|(\s*$)/g, & ...

  5. 实现移动端touch事件的横向滑动列表效果

    要实现手机端横向滑动效果并不难,了解实现的原理及业务逻辑就很容易实现.原理:touchstart(手指按下瞬间获取相对于页面的位置)——>touchmove(手指移动多少,元素相应移动多少). ...

  6. android 多渠道打包

    android 多渠道打包 原理 在manifest文件中,application标签内部设置不同的metadata标签即可,可以通过java api获取这个matedata内的值 友盟提供的多渠道打 ...

  7. maven升级遇到的疑惑

    今天在解决一个问题的时候,由于需要修改maven的client包,按照之前的办法,修改完之后,没有修改版本号,而是直接修改client的代码,之后直接 mvn deploy -e 打包上去了,然后奇怪 ...

  8. Netty入门2之----手动搭建HttpServer

    在上一章中我们认识了netty,他有三大优点:并发高,传输快,封装好.在这一章我们来用Netty搭建一个HttpServer,从实际开发中了解netty框架的一些特性和概念. netty.png 认识 ...

  9. “云中论道”之——使用开源技术和Azure公有云服务快速搭建云端IoT解决方案(上)

    “云中论道”技术课堂第一课开讲啦!微软各路技术咖们齐聚一堂,为大家带来干货不断!作为“云中论道“课堂的开课之作,我们首先邀请到了微软Azure专家级的架构师:槐长清,他为我们带来了关于“使用开源技术和 ...

  10. Oracle案例01——ORA-09925: Unable to create audit trail file

    2018年春节后第一天上班就遇到一个审计日志无法写入的问题,具体解决思路如下. 一.错误日志 数据库错误日志内容: Fri Feb 23 11:16:30 2018OS Audit file coul ...