下载此文档

iOS开发 Orientation 屏幕旋转.doc


文档分类:IT计算机 | 页数:约7页 举报非法文档有奖
1/7
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/7 下载此文档
文档列表 文档介绍
iOS开发 Orientation 屏幕旋转
现在随着手机屏幕的增大,很多项目都是竖屏控制的,但是,也有需要横屏的时候,现在将方法整理一下。1 项目中General 设置,图1是iOS7之前的版本,图2是iOS7之后的版本。
2 代码枚举值
UIDeviceOrientationUnknown,
UIDeviceOrientationPortrait, // Device oriented vertically, home button on the bottom
UIDeviceOrientationPortraitUpsideDown, // Device oriented vertically, home button on the topUIDeviceOrientationLandscapeLeft, // Device oriented horizontally, home button on the right
UIDeviceOrientationLandscapeRight, // Device oriented horizontally, home button on the left
UIDeviceOrientationFaceUp, // Device oriented flat, face up
UIDeviceOrientationFaceDown // Device oriented flat, face down */

3 控制旋转的方法
-(BOOL)shouldAutorotate
{
// return NO;//不允许随着设备旋转
return YES;
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAllButUpsideDown;
// 直接返回支持的旋转方向,该方法在iPad上的默认返回值是UIInterfaceOrientationMaskAll,
//iPhone上的默认返回值是UIInterfaceOrientationMaskAllButUpsideDown
} 4 项目实现方式
A. 强制横屏 选择了旋转屏幕View
-(void)buildStageRotate
{
= CGAffineTransformMakeRotation(M_PI_2);
}

在- (void)viewDidLoad {}里面添加观察者
[[NSNotificationCenter defaultCenter] addObserver:self selector:***@selector(orientChange:) name:UIDeviceOrientationDidChangeNotification object:nil];
实现效果
-(void)orientChange:(NSNotification *)notif

iOS开发 Orientation 屏幕旋转 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数7
  • 收藏数0 收藏
  • 顶次数0
  • 上传人学习的一点
  • 文件大小13 KB
  • 时间2021-10-09
最近更新