设置视图控制器的旋转方向
2015-10-11 15:56
309 查看
设置视图控制器的旋转方向
//当控制器旋转的时候执行的方法 /* typedef NS_ENUM(NSInteger, UIInterfaceOrientation) { UIInterfaceOrientationUnknown = UIDeviceOrientationUnknown, UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait, UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown, UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight, UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft }; */ - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ CGFloat width = [UIScreen mainScreen].bounds.size.width; CGFloat height = [UIScreen mainScreen].bounds.size.height; switch (toInterfaceOrientation) { case UIInterfaceOrientationPortrait: case UIInterfaceOrientationPortraitUpsideDown: { UIView *view = [self.view viewWithTag:100]; view.frame = CGRectMake((width - 100) / 2, (height - 100) / 2, 100, 100); break; } case UIInterfaceOrientationLandscapeLeft: case UIInterfaceOrientationLandscapeRight: { UIView *view = [self.view viewWithTag:100]; view.frame = CGRectMake((height - 100) / 2, (width - 100) / 2, 100, 100); break; } default: break; }
相关文章推荐
- 成段异或更新 poj3255 Help with Intervals
- 如何从技术牛人升阶为管理牛人
- Golang学习笔记:语言规范之词汇元素和类型
- hdu4096(模拟)
- 最值、最大公约数、最小公倍数
- hdu4091(暴力)
- 面向对象编程的三大特征
- 【SSH三框架】Struts2第一章的基础:第一次写Struts2规划
- keytool 错误 java.io.IOException: incorrect AVA format
- 程序员书单_HeadFirst系列
- php mkdir函数
- ios开发实践
- 成段覆盖更新+离散化 求建筑的平面覆盖面积 poj3277 City Horizon
- 新的时代需要新的领导力!
- 新的时代需要新的领导力!
- git基本操作
- 程序员书单_HeadFirst系列
- VisualVM目录解析
- 程序员书单_移动开发篇
- 西门子PLC Modbus写入float字节排列