【问题标题】:Not respond on willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration不响应 willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 持续时间:(NSTimeInterval)duration
【发布时间】:2012-12-19 15:20:08
【问题描述】:

我有代码

-(BOOL) shouldAutorotate
{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    [super willAnimateRotationToInterfaceOrientation: toInterfaceOrientation duration: duration];
    deviceOrientation = toInterfaceOrientation;
    if(deviceOrientation == UIInterfaceOrientationPortrait)
    {
        curPageSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height-STATUS_BAR_HEIGHT);      
    }
    else if(deviceOrientation == UIInterfaceOrientationLandscapeLeft || deviceOrientation == UIInterfaceOrientationLandscapeRight)
    {
        curPageSize = CGSizeMake([UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width-STATUS_BAR_HEIGHT);
    }
    [self correctViews:curPageSize];
}

这些方法在 ModalViewController 中定义... 当我旋转设备时,程序不响应 willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration...

我该怎么办?!

【问题讨论】:

    标签: ios6


    【解决方案1】:

    尝试将您的代码调整为类似这样的内容...我已在许多应用程序中成功使用此方法。编码愉快!

    -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
    {
        [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
        if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
        {
            //Landscape
            self.ViewL.frame = CGRectMake(0, 0, 1024, 728);
            self.ViewL.hidden=NO;
            self.ViewP.hidden=YES;
    
        }
        else
        {
            //Portrait
            self.ViewP.frame = CGRectMake(0, 0, 768, 955);
            self.ViewP.hidden=NO;
            self.ViewL.hidden=YES;
    
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-31
      相关资源
      最近更新 更多