Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Monaj

macrumors regular
Original poster
May 24, 2009
193
0
Hi all,

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


Code:
-(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;
        }

Sometime it is working fine but sometime 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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.