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新建项目不能全屏
上个周做项目的时候,发现新建了一个项目不能全屏.伤透了我的脑筋,然后又请教了团队里其他两个大牛帮我搞定了这个问题. 虽然是搞定了,但也看的出大牛也是云里雾里.歪打正着解决的. 今天又想新做个项目,这个 ...
随机推荐
- mockjs
首先还是那句话,进来的GodBoy and GoodGirl 不妨看完再离开. 一个走在路上的前端攻城狮-along 一.mock的由来 mock有“愚弄.欺骗”之意,在前端领域,mock可以理解为 ...
- 优秀iOS文章集合
Runtime 10种用法(没有比这更全的了成为iOS顶尖高手,你必须来这里(这里有最好的开源项目和文章)iOS逆向Reveal查看任意app 的界面JSPatch (实时修复App Store bu ...
- JAVA基本数据类型、引用数据类型-参数传递详解
1:基本类型的参数传值 对于基本数据类型,修改这个值并不会影响作为参数传进来的那个变量,因为你修改的是方法的局部变量,是一个副本.实参的精度级别应等于或低于形参的精度级别,否则报错. class JB ...
- KLEE错误汇报一:One phenomenon after the execution using klee
https://github.com/klee/klee/issues/649#issuecomment-300424204 Hi, all, If you write test.c wit ...
- swoole 创建tcp服务器
server.php <?php /** * 创建tcp服务器 * Date: 2019/1/15 */ $serv = new swoole_server('127.0.0.1', 9501) ...
- 网站的Information Architecture--构建一个最优用户体验的site structure
http://conversionxl.com/website-information-architecture-optimal-user-experience/ 在网站上应该有什么类型的conten ...
- phpstorm2017使用快捷键
切换到的是NetBeans的皮肤: 1.在行添加一个书签, ctrl+鼠标左键 2.查找添加的书签, ctrl+shift+M 3.关闭项目 选择file->close project
- Eclipse版本推荐(tomcat运行项目:web、maven)
1.区别 Eclipse根据特性和jdk版本,从Eclipse官网可看到,分为:Neon/Oxygen/Mars/Luna/Kepler/Juno/Indigo/Helios...等等. Eclips ...
- js 更改对象中的属性名
const json = JSON.parse(JSON.stringify(options).replace(/name/g,"label")); 注: 1.options是需要 ...
- July 01st 2017 Week 26th Saturday
Kind hearts are more than coronets. 善良的心灵胜于显贵的地位. Some people say that this is a dog-eat-dog world, ...