【发布时间】:2009-03-02 05:55:16
【问题描述】:
我正在开发一款使用横向模式的游戏,我总共有 4 个视图。 2 个视图在横向模式下正确出现。但在第三个视图中,我有 UITable 和导航栏。我可以在横向模式下旋转表格,但不能转换导航栏和导航控制器。导航栏和导航控制器上也有按钮。它也没有得到转变。那么任何人都可以对此有解决方案。 :)
【问题讨论】:
标签: iphone objective-c cocoa-touch
我正在开发一款使用横向模式的游戏,我总共有 4 个视图。 2 个视图在横向模式下正确出现。但在第三个视图中,我有 UITable 和导航栏。我可以在横向模式下旋转表格,但不能转换导航栏和导航控制器。导航栏和导航控制器上也有按钮。它也没有得到转变。那么任何人都可以对此有解决方案。 :)
【问题讨论】:
标签: iphone objective-c cocoa-touch
#define degreesToRadians(x) (M_PI * x / 180.0)
- (void)viewWillAppear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
CGRect newBounds = CGRectMake(0, 0, 480, 320);
self.navigationController.view.bounds = newBounds;
self.navigationController.view.center = CGPointMake(newBounds.size.height / 2.0, newBounds.size.width / 2.0);
self.navigationController.view.transform = CGAffineTransformMakeRotation(degreesToRadians(90));
[super viewWillAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
self.navigationController.view.transform = CGAffineTransformIdentity;
self.navigationController.view.transform = CGAffineTransformMakeRotation(degreesToRadians(0));
self.navigationController.view.bounds = CGRectMake(0.0, 0.0, 320.0, 480.0);
[super viewWillDisappear:animated];
}
【讨论】:
将导航控制器的导航栏旋转 90 度。 此外,您可能需要设置导航栏中心和框架以设置适当的宽度以适应横向模式..它对我有用:) 希望对你也有帮助。
【讨论】:
在 UIViewController 文档的 Class 中:
处理轮换
interfaceOrientation 属性
– shouldAutorotateToInterfaceOrientation:
– 旋转页脚视图
– 旋转标题视图
– willRotateToInterfaceOrientation:duration:
– willAnimateFirstHalfOfRotationToInterfaceOrientation:duration:
– willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration:
– didRotateFromInterfaceOrientation:
希望这对你也有帮助。
一个。
【讨论】: