简体   繁体   English

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

[英]Why is my iPad app not detecting orientation change?

Using the following code gives me nothing... My view rotates. 使用以下代码没有任何帮助...我的视图旋转。 Can't understand it... 听不懂...

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


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

Thanks... 谢谢...

This may be due to the way your VC is nested inside a heirarchy of VC's. 这可能是由于您的VC嵌套在VC的层次结构中的原因。

This SO post should help you out: 这样的帖子应该可以帮助您:

-(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");

    }
}

and leave this like how it was 并保持原样

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM