模拟器中的旋转视图不起作用

时间:2011-06-09 13:44:44

标签: objective-c xcode ipad ios4 rotation

在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);

}

}

但是当我在模拟器或设备中播放应用程序时,旋转不起作用。它仅在纵向模式下显示。我究竟做错了什么?任何想法?

P.S。我正在使用XCode 4.0.2,应用程序适用于iPad

1 个答案:

答案 0 :(得分:0)

你的意思是在UIViewController中......不是UIView对吗?那些方法在控制器中不在视图级别....