所有界面锁定屏幕方向,某一个界面支持屏幕旋转~
2015-10-16 10:25
429 查看
//appdelagate.h 加
@property (nonatomic, assign) BOOL allowRotation;
//appdelegate.m加
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (self.allowRotation) {
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
return UIInterfaceOrientationMaskPortrait;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
打开屏幕旋转:
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
delegate.allowRotation = YES;
关闭屏幕旋转:
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
delegate.allowRotation = NO;
@property (nonatomic, assign) BOOL allowRotation;
//appdelegate.m加
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (self.allowRotation) {
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
return UIInterfaceOrientationMaskPortrait;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
打开屏幕旋转:
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
delegate.allowRotation = YES;
关闭屏幕旋转:
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
delegate.allowRotation = NO;
相关文章推荐
- 【Android学习笔记】 画图
- Google translate API 调用方法
- struts2的namespace
- shell中可能经常能看到:>/dev/null 2>&1
- jsp中的简单文件上传
- eclipse 方便快捷安装svn
- 粒子生物学【经济学人】
- 解决:对 PInvoke 函数的调用导致堆栈不对称问题
- OgreSDK_Android_v1-9-0RC1 --Android 环境搭建
- FineReport——函数
- 粒子生物学【经济学人】
- centos配置yum源
- Android中webview和js之间的交互
- c中select的理解
- popwindow 位置和动画
- jboss(一)--安装
- Eclipse使用技巧
- Benchmark性能测试工具,TestDFSIO/TeraSort
- JSF框架认识
- 从高版本JDK换成低版本JDK报错Unsupported major.minor version 52.0