手动设置竖屏:修改currentDevice orientation需要在setStatusBarOrientation前
bool IsIOS8 = NO; float version = [[[UIDevice currentDevice] systemVersion] floatValue]; if (version >= 8.0) { IsIOS8 = YES; } //改设备方向 //if (IsIOS8) { [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIInterfaceOrientationPortrait] forKey:@"orientation"]; //} [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
UIApplication需要实现方法或者监听UIApplicaionDelegate委托回调
方法 1)UIApplication需要实现
-(NSUInteger)supportedInterfaceOrientations { UIDeviceOrientation deviceOrientation = [[UIDevice currentDevice] orientation]; UIInterfaceOrientation statusBarOrientation =[UIApplication sharedApplication].statusBarOrientation; if(deviceOrientation == UIDeviceOrientationPortrait || deviceOrientation == UIDeviceOrientationPortraitUpsideDown){ if(statusBarOrientation != UIInterfaceOrientationPortrait ||statusBarOrientation != UIInterfaceOrientationPortraitUpsideDown){ return 0; } } // otherwise return UIInterfaceOrientationMaskLandscape; }
方法 2)UIApplicaionDelegate委托接口
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { UIDeviceOrientation deviceOrientation = [[UIDevice currentDevice] orientation]; UIInterfaceOrientation statusBarOrientation =[UIApplication sharedApplication].statusBarOrientation; if(deviceOrientation == UIDeviceOrientationPortrait || deviceOrientation == UIDeviceOrientationPortraitUpsideDown){ if(statusBarOrientation != UIInterfaceOrientationPortrait ||statusBarOrientation != UIInterfaceOrientationPortraitUpsideDown){ return 0; } } // otherwise return UIInterfaceOrientationMaskLandscape; // UIInterfaceOrientationMaskAll // it is the safest way of doing it: // - GameCenter and some other services might have portrait-only variant // and will throw exception if portrait is not supported here // - When you change allowed orientations if you end up forbidding current one // exception will be thrown // Anyway this is intersected with values provided from UIViewController, so we are good //return (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationPortraitUpsideDown) //| (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationLandscapeLeft); }
相关推荐
这是一个iOS中播放器横竖屏切换的demo
最近研究了一下关于视频播放的东西,之前都是加载网页或者用MPMoviePlayerViewController直接弹出播放,横竖屏的切换都是通过手机自带的竖屏开关设置实现的,所以用户体验并不是太好,这里的demo在不通过横竖屏开关...
IOS横竖屏切换的demo,供初学IOS小伙伴参考
iOS系统键盘的按键音效
iOS视频全屏时锁定横竖, iOS 9.3测试有效.
//屏幕方向标识,0横屏,其他值竖屏 var orientation=0; //转屏事件,内部功能可以自定义 function screenOrientationEvent(){ if(orientation == 0)document.getElementById("change").value="竖"; else document...
iOS 屏幕设置框架 Bohr ,Bohr 是一个设置屏幕组成的框架。
iOS模拟点击屏幕,自动化脚本,点击手势等模拟操作 iOS模拟点击屏幕,自动化脚本,点击手势等模拟操作 iOS模拟点击屏幕,自动化脚本,点击手势等模拟操作 iOS模拟点击屏幕,自动化脚本,点击手势等模拟操作 iOS模拟...
IOS横竖屏切换,指定界面横屏显示的例子程序
1.视频项目时某些页面需支持横屏,而其他页面只需支持竖屏 2.demo连接地址:https://github.com/Jude309307972/RotateDemo
越狱后设置ios9拨号按键钢琴音 内附教程
iOS模拟点击屏幕,自动化脚本,点击手势等模拟操作 iOS模拟点击屏幕,自动化脚本,点击手势等模拟操作 iOS模拟点击屏幕,自动化脚本,点击手势等模拟操作 iOS模拟点击屏幕,自动化脚本,点击手势等模拟操作
iOS项目中有很多项目都可能是大多数界面只支持竖屏,只有个别的界面需要横竖屏切换,或者强制横屏,本篇Demo,很好的解决了这个问题
是研究ios屏幕共享时编制的demo,重点参考了如下两个开源项目: 1 http://www.gdcl.co.uk/2013/02/20/iOS-Video-Encoding.html (ios 上h.264硬编码,RTSP服务端) 2 https://github.com/coolstar/RecordMyScreen ...
iOS基本通知屏幕。.zip,iOS基本通知屏幕
iOS页面亮度高亮,跳转到二维码页面屏幕变亮,退出恢复系统亮度,以及按”Home“键后通过系统代理设置系统的亮度
播放器横竖屏切换,左右滑动手势快进 想要控制横竖屏切换,第一步首先创建一个继承自UINavigationController的类,重写方法 第二步在UIViewController里加上 - (BOOL)shouldAutorotate{return NO;} ...
让你轻松学代理,之后学会运用;通过代理我们可以进行传值;该传值后页向前页的传值;与属性传值相反
真机调试时会卡,问题出在截取2dview图像和文件写入那里了,把他放到内存就不卡了,换个截view得方式就不卡了。这俩一改就ok,ok的代码我懒的摘了就不传或以后传了,有问题请联系qq1101629532
(CAShapelayer UIBezierPath)绘制K线支撑横竖屏切换、刷新、长按、缩放、masonry适配,完美支持金融产品 非常的流畅,占用内存少,使用矢量进行填充K线 由于项目比较大,下载请移步GitHub:...