我在iPhone应用程序中使用委托方法进行自动旋转。iphone发生风景时的问题
-(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;
}
旋转为横向模式时,它正在开发iPhone OS3,但在iPhone OS4精致,界面显示不正确
当旋转回纵向模式接口压缩... 。
请问我建议我怎么解决?
由于
迪皮卡
我不知道这是不是问题,但你有很多硬编码的数字 - 你应该尽量使用计算的值,只要你可以,而不是320你应该使用self.view.frame.size 。宽度; – deanWombourne 2010-07-02 08:15:29