某一页面强制横屏
来源:互联网 发布:flash cs6 mac版 编辑:程序博客网 时间:2024/06/04 19:16
某一页面强制横屏:
一、首先
在项目里面设置Device Orientation允许转屏的方向,下面设置了竖屏,和横屏(横屏左右根据home键确定):
二、AppDelagate代码
AppDelagate.h文件
@property (nonatomic,assign)BOOL allowRotation;//方向
AppDelagate.m文件
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)nowWindow {
if (_allowRotation == YES) {
return UIInterfaceOrientationMaskLandscapeLeft;
}
return UIInterfaceOrientationMaskPortrait;
}
三、然后在需要横屏的页面里:
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self allowRotationIsYesOrNo:YES];
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self allowRotationIsYesOrNo:NO];
}
-(void)allowRotationIsYesOrNo:(BOOL)isYesOrNo{
AppDelegate * appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
appDelegate.allowRotation = isYesOrNo;
[self SetTheScreenDirection:isYesOrNo];//调用转屏代码
}
//转屏
- (void)SetTheScreenDirection:(BOOL)fullscreen
{
if (fullscreen) {
NSNumber *resetOrientationTarget = [NSNumber numberWithInt:UIInterfaceOrientationUnknown];
[[UIDevice currentDevice] setValue:resetOrientationTarget forKey:@"orientation"];
NSNumber *orientationTarget = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft];
[[UIDevice currentDevice] setValue:orientationTarget forKey:@"orientation"];
}else{
NSNumber *resetOrientationTarget = [NSNumber numberWithInt:UIInterfaceOrientationUnknown];
[[UIDevice currentDevice] setValue:resetOrientationTarget forKey:@"orientation"];
NSNumber *orientationTarget = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
[[UIDevice currentDevice] setValue:orientationTarget forKey:@"orientation"];
}
}
- 某一页面强制横屏
- [绍棠] 进入某一界面强制横屏
- ios 强制改变某一页面屏幕方向
- 某个页面强制横屏
- 项目中某个页面强制横屏
- iOS实现单个页面强制横屏
- 移动端如何强制页面横屏
- iOS 个别页面强制横屏,其他页面竖屏
- iOS 个别页面强制横屏,其他页面竖屏
- iOS 个别页面强制横屏,其他页面竖屏
- iOS 指定页面允许旋转/ 指定页面强制横屏
- iOS 项目中,特定页面强制横屏
- 移动端如何让页面强制横屏
- iOS开发Debug之单个页面强制横屏
- 移动端如何让页面强制横屏
- 移动端如何让页面强制横屏
- 手机上如何让页面强制横屏
- 移动端如何让页面强制横屏
- 通过Tomcat的manager app管理web项目
- C#中的Datatable(初步)
- RocketMQ初识
- [BZOJ 2326] 数学作业
- Coupons UVA
- 某一页面强制横屏
- Day 1:Eclipse创建Android模拟器
- JavaScript实现阿拉伯数字和中文数字互相转换
- js验证汉字正则表达式
- SSIS(简单数据抽取过程介绍)
- javascript在闭包中使用this对象
- Eclipse快捷方式
- Eslint 从入门到放弃
- Angular表达式