当前位置: 移动技术网 > IT编程>移动开发>IOS > iOS中将个别页面强制横屏其他页面竖屏

iOS中将个别页面强制横屏其他页面竖屏

2019年07月24日  | 移动技术网IT编程  | 我要评论

natr-241,英语名言警句大全,seyuse8

 在appdelegate.h里面添加@property(nonatomic,assign)nsinteger allowrotation;

在appdelegate.m文件里面添加

- (nsuinteger)application:(uiapplication *)application supportedinterfaceorientationsforwindow:(uiwindow *)window
 {
   if (_allowrotation == 1) {
     return uiinterfaceorientationmasklandscaperight;
   }
   else
   {
     return (uiinterfaceorientationmaskportrait);
   }
 }

这样默认所以的页面就是竖屏的,在要强制横屏的页面的控制器uiviewcontroller里面,引入#import “appdelegate.h”
然后

(void)viewdidload 
{ 
[super viewdidload]; 
appdelegate * appdelegate = (appdelegate *)[uiapplication sharedapplication].delegate; 
appdelegate.allowrotation = 1; 
}

就可以让个别页面单独横屏了,在跳出这个横屏页面前修改状态,如下

appdelegate *delegate = [[uiapplication sharedapplication]delegate];
  delegate.allowrotation = 0;

这样既可完整的实现页面的横屏。

以上所述是小编给大家介绍的ios中将个别页面强制横屏其他页面竖屏,希望对大家有所帮助

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网