0

我正在使用幻灯片过渡,

通过使用此代码,

        Home *lisnx = [[Home alloc] init];
        CATransition *animation = [CATransition animation];
        [self presentModalViewController:lisnx animated:NO];
        [animation setDuration:0.40];
        [animation setType:kCATransitionPush];
        [animation setSubtype:kCATransitionFromLeft];
        [[lisnx.view layer] addAnimation:animation forKey:@"SwitchToView1"];
        [lisnx release];

但是在横向模式下,当我从一个视图移动到另一个视图时,每一件事都向右移动,我使用了这个代码,

        self.view.bounds=CGRectMake(0.0,0.0,480.0,320.0);
        scroll.frame=CGRectMake(0.0,0.0,480.0,320.0);
        bgImg.frame=CGRectMake(0.0,0.0,480.0,320.0);

如何摆脱这个问题请一些人帮助我。

4

1 回答 1

0

您需要为每个视图提供不同的框架,对于纵向以及横向。

UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
    scroll.frame=CGRectMake(0.0,0.0,480.0,320.0); 
    ...            
 } 
else {

 scroll.frame=CGRectMake(0.0,200.0,200.0,320.0);
 ...
}

在这里给你的框架,

于 2012-06-04T12:08:23.117 回答