解释:当然也可以选择应用Masonry如许优良的AutoLayout构造第三方库来处理,storyBoard来构冒昧之。
4、屏幕扭转下处理Demo效不雅图
竖屏下效不雅.png
横屏下效不雅.png
5、屏幕扭转处理的建议
1)扭转前后,view当前显示的地位尽量不变
2)扭转过程中,临时界面操作的响应
3)视图中有tableview的话,扭转后,强迫 [tableview reloadData],包管在偏向变更今后,新的row可以或许充斥全屏。
四、强迫横屏
APP中某些页面,如视频播放页,一出现就请求横屏。这些横屏页面或模态弹出、或push进来。
1、模态弹出ViewController情况下 强迫横屏的设置
- //QSShow3Controller.m
- - (BOOL)shouldAutorotate{
- return NO;
- }
- - (UIInterfaceOrientationMask)supportedInterfaceOrientations{
- return UIInterfaceOrientationMaskLandscapeRight;
- }
- - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
- return UIInterfaceOrientationLandscapeRight;
- }
- //模态弹出
- QSShow3Controller *vc = [[QSShow3Controller alloc]init];
- [self presentViewController:vc animated:YES completion:nil];
解释:这种情况比较简单处理。
【编辑推荐】
- iOS ReactiveCocoa 最全常用API整收成可做为手册萌芽)
- 优化iOS法度榜样机能的二十五个办法
- iOS编程中throttle的那些事
- 苹不雅iOS 11或不再支撑32位 海量老APP面对作废
- iOS与Android设备到底是若何被入侵的?
2、push推入ViewController情况下 强迫横屏的设置
- //QSShow4Controller.m
- -(void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- [self setInterfaceOrientation:UIInterfaceOrientationLandscapeRight];
- }
- //强迫转屏(这个办法最好放在BaseVController中)
- - (void)setInterfaceOrientation:(UIInterfaceOrientation)orientation{
- if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
- SEL selector = NSSelectorFromString(@"setOrientation:");
- NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
推荐阅读
近年来,Python 在数据科学行业扮演着越来越重要的角色。是以,我根据比来的应用体验,在本文中列出了对数据科学家、工程师们最有效的那些库。因为这些库都开源了,我们大年夜Github上惹人>>>详细阅读
本文标题:代码处理iOS的横竖屏旋转
地址:http://www.17bianji.com/lsqh/36388.html
1/2 1