简体   繁体   中英

UIView Slide Transition,in view based Application

I am using slide transition,

by using this code,

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

but in landscape mode when i move from one view to another view every thing shifted right for landscape i have used this code,

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

How to way out from this problem please some body help me.

you need to give different frame to each view, for Portrait as well Landscape.

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

give your frame here,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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