【发布时间】:2011-09-11 17:36:34
【问题描述】:
在 UIViewController 实现中,我重写了 shouldAutorotateToInterfaceOrientation 方法并返回 YES(或 TRUE)。我也重写了这个方法:
-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
image.frame = CGRectMake(448, 381, 128, 113);
progresView.frame = CGRectMake(448, 498, 130, 11);
activityIndicator.frame = CGRectMake(448, 514, 20, 20);
statusLabel.frame = CGRectMake(473, 534, 97, 18);
} else {
image.frame = CGRectMake(335, 643, 128, 113);
progresView.frame = CGRectMake(335, 760, 130, 11);
activityIndicator.frame = CGRectMake(335, 776, 20, 20);
statusLabel.frame = CGRectMake(360, 776, 97, 18);
}
}
但是当我在模拟器或设备中播放应用程序时,旋转不起作用。它仅在纵向模式下显示。我究竟做错了什么?有什么想法吗?
附:我正在使用 XCode 4.0.2,应用程序适用于 iPad
【问题讨论】:
-
我只是想指出,您可以使用 UIDeviceOrientationIsLandscape 宏,而不是自己检查 LandscapLeft 和 LandscapeRight。 UIKit Function Reference
标签: objective-c xcode ipad ios4 rotation