views:

37

answers:

1

Hi all,

I am using the delegate method for auto rotation in iphone application.

    -(BOOL)shouldAutorotateToInterfaceOrientation:UIInterfaceOrientation)interfaceOrientation{

    if(interfaceOrientation  == UIInterfaceOrientationPortrait ){
            [UIView beginAnimations:@"View Flip" context:nil];
            [UIView setAnimationDuration:0.2f];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            self..view.transform = CGAffineTransformMakeRotation(0);
            self.view.bounds = CGRectMake(0,0,320,460);
            [UIView commitAnimations];
            self.navigationBar.frame=CGRectMake(0, 0, 320, 44);


        }else if(interfaceOrientation  == UIInterfaceOrientationLandscapeRight){

            [UIView beginAnimations:@"View Flip" context:nil];
            [UIView setAnimationDuration:0.2f];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            CGAffineTransform transform = CGAffineTransformMakeRotation(3.14159/2);
            self.view.transform = transform;
            CGRect contentRect = CGRectMake(10, -10, 480, 300);
            self.view.bounds = contentRect;
            [UIView commitAnimations];

            self.navigationBar.frame=CGRectMake(0, 0, 480, 32);

        }else if(interfaceOrientation  == UIInterfaceOrientationLandscapeLeft){
            //navigationController.navigationBar.frame=CGRectMake(0, 0, 480, 34);
            [UIView beginAnimations:@"View Flip" context:nil];
            [UIView setAnimationDuration:0.2f];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            CGAffineTransform transform = CGAffineTransformMakeRotation(-3.14159/2);
            self.view.transform = transform;
            CGRect contentRect = CGRectMake(-10, -10, 480, 300);
            self.view.bounds = contentRect;
            [UIView commitAnimations];

            self.navigationBar.frame=CGRectMake(0, 0, 480, 32);
        }else if(interfaceOrientation  == UIInterfaceOrientationPortraitUpsideDown ){
               return NO;
        }
        return YES;
    }

It is working fine on iphone OS3 but on iphone OS4, when rotating to landscape mode, the interface displays incorrectly (http://www.freeimagehosting.net/image.php?2edf4a9702.png) When rotating back to portrait mode the interfaces compresses....(http://www.freeimagehosting.net/image.php?2da25c4c07.png)

Please suggest me any suggestion how I resolve it ??

Thanks
Deepika

A: 

CGRect contentRect = CGRectMake(-10, -10, 480, 300); self.view.bounds = contentRect;

why you giving -10,-10 ? any specific reason .This is completely due to frame mismatching. Just change that frame and check it.

sandy
I set (-10 ,-10) for just poisoning of view on screen....I m using ipod(Version 3.1.3)..on this iPod it is working fine...but on iPhone 4.0,it is not working.
Deepika
iOS4 having a lot of issue.So code working fine in 3.0 series doesn't mean must work fine for iOS4. i think this is frame maintaining issue. Just change the frame and also change the background color of all the subviews than you exact frame of each view. Try once ....
sandy