- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)
toInterfaceOrientation duration:(NSTimeInterval)duration {
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft
|| toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
[scrollView setFrame:CGRectMake(0, 0, 568, 320)];
[scrollView setContentOffset:CGPointMake(leftLabel.frame.size.width - 284.0f, 0.0f)animated:YES];
}
else
{
scrollView.contentSize = CGSizeMake(leftLabel.frame.size.width +rightLabel.frame.size.width, leftLabel.frame.size.height);
[scrollView setContentOffset:CGPointMake(leftLabel.frame.size.width - 160.0f, 0.0f)animated:YES];
}
}
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return [self.navigationController supportedInterfaceOrientations];
}
本文介绍iOS应用中如何处理屏幕从横屏到竖屏的转换,包括view大小和坐标的变化。针对iOS 6.0及以后版本,介绍了新的屏幕旋转方法,并提供了一个具体的实现示例。

4547

被折叠的 条评论
为什么被折叠?



