我在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