Issue when iphone takes place the Landscape Orientation
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
When rotating back to portrait mode the interfaces compresses....
Please suggest me any suggestion how I resolve it ??
Thanks
DeepikaCGRect 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.
精彩评论