为什么我的iPad应用程序没有检测到方向变化?

时间:2012-01-25 16:25:10

标签: objective-c ios ipad orientation

使用以下代码什么都没有...我的视图旋转。无法理解......

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}


- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    NSLog(@"I am starting to rotate");
}

...谢谢

2 个答案:

答案 0 :(得分:0)

这可能是由于VC嵌套在VC层次结构中的方式。

This SO帖子可以帮助你:

答案 1 :(得分:0)

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
    if(self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
       self.interfaceOrientation == UIInterfaceOrientationLandscapeRight){
           NSLog(@"I am starting to rotate in Landscape");

    } else {
           NSLog(@"I am starting to rotate in Portrait");

    }
}

并留下它的样子

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}