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. js数组方法 改变原数组和不改变原数组的方法整理

    改变原数组: pop():   删除 arrayObject 的最后一个元素,把数组长度减 1,并且返回它删除的元素的值.如果数组已经为空,则 pop() 不 改变数组,并返回 undefined 值 ...

  2. canvas合成图片 圣诞节新技能戴帽

    <!doctype html><html><head><meta charset="utf-8"><title>Html ...

  3. 【转】ArcGIS Server10.1安装常见问题及解决方案

    转载自:http://www.higis.cn/Tech/tech/tId/85/ 最近因为更换系统的原因,重新安装了ArcGISServer 10.1.过程中遇到了几个小问题,虽然都一一解决了,但也 ...

  4. addEventListener(event, function, useCapture) 简记

    监听事件方法:addEventListener(<event-name>, <callback>, <use-capture>) 移除监听事件方法:removeEv ...

  5. js if语句只写一个参数是什么意思?

    如 var a=0:if(!a){...}; avascript中以下值会被转换为false false undefined null 0 -0 NaN ""

  6. Java基础之final和static关键字

    一.final        根据程序上下文环境,它可以修饰非抽象类.非抽象类成员方法和变量.         final类不能被继承,没有子类,final类中的方法默认是final的.        ...

  7. java自增(自减)运算符

    自增(自减)运算符: ++ --就是可以将当前变量自我增加(减少)1 的运算符. i++, 后++, 先将 i 的值作为整个表达的值, 然后将 i 增加 1. ++i, 先++, 先将 i 增加 ...

  8. C++ Notes 1 - size_type - Accelerated Ch3

    1. 为什么用string::size_type而不是int? --Why use string::size_type ? int is supposed to work! it holds numb ...

  9. 你所不知道的C和C++运行库 标签: vc 2017-05-26 10:33 41人阅读 评论(0) 收藏

    在使用vs2013调用vc2005编译出的dll时出现错误,遂将源程序用vs2013编译出dll,再用vs2013调用错误消失,不解.寻找原因时有人说"VC库版本不一样",故查找C ...

  10. leveldb分析——单元测试工具

    leveldb中自己实现了一个简单的单元测试工具,下面是一个对CRC类测试的一个例子 class CRC { }; TEST(CRC, Extend) { ASSERT_EQ(Value(), Ext ...