UIView幻灯片切换,基于视图的应用程序

时间:2012-06-02 11:09:10

标签: iphone objective-c ios xcode

我正在使用幻灯片转换,

使用此代码,

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

如何解决这个问题请一些人帮助我。

1 个答案:

答案 0 :(得分: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);
 ...
}

在这里给你的框架,