- 设置程序支持的旋转方向
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeLeft |
UIInterfaceOrientationMaskPortrait;
} - 设置当屏幕旋转到不同方向时显示不同的内容
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
switch (toInterfaceOrientation) {
case UIInterfaceOrientationLandscapeLeft:
NSLog(@”小爷在左”);
break;
case UIInterfaceOrientationLandscapeRight:
NSLog(@”小爷在右”);
break;
case UIInterfaceOrientationPortrait:
NSLog(@”苍天在上”);
break;
case UIInterfaceOrientationPortraitUpsideDown:
NSLog(@”厚土为下”);
break;
default:
break;
}
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
- 可以根据设备的当前方向,设定要显示的数据列数 ;由于横屏与竖屏宽度的不同要设置不同的数据来接收
(瀑布流里面可以用到)
if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeLeft || [UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeRight) {
self.dataColumns = 4;
} else {
self.dataColumns = 3;
}
屏幕的旋转控制
最新推荐文章于 2024-04-16 12:50:50 发布