Tutorial :Issue when iphone takes place the Landscape Orientation



Question:

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

Landscape

When rotating back to portrait mode the interfaces compresses.... Portrait

Please suggest me any suggestion how I resolve it ??

Thanks
Deepika


Solution:1

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.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »