1

私はコードを持っています

-(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に応答しません...

私は何をすべきか?!

4

1 に答える 1

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;

    }
}
于 2012-12-03T21:47:33.127 に答える