首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在横向模式下转换导航栏和导航控制器

问如何在横向模式下转换导航栏和导航控制器
EN

Stack Overflow用户
提问于 2009-03-02 05:55:16
回答 3查看 4.1K关注 0票数 5

我正在开发一个游戏,其中我使用的是景观模式,我有总共4个视图。2个视图在横向模式中正常出现。但在第三个视图中,我有UITable和导航栏。我可以在横向模式下旋转桌子,但不能转换导航栏和导航控制器。导航栏和导航控制器上也有按钮。它也不会被转换。因此,任何人都可以对此有解决方案。:)

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2009-03-02 07:28:29

将导航控制器的导航栏旋转90度来改变它。此外,您可能需要设置导航栏的中心和框架,以设置适当的宽度,以适应风景mode..it工作为我:)希望它也能帮助你。

票数 2
EN

Stack Overflow用户

发布于 2011-12-01 01:53:53

代码语言:javascript
复制
#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];
}
票数 7
EN

Stack Overflow用户

发布于 2009-03-02 09:53:49

在UIViewController文档的类中:

处理旋转

interfaceOrientation属性

- shouldAutorotateToInterfaceOrientation:

- rotatingFooterView

- rotatingHeaderView

-willRotateToInterfaceOrientation:持续时间:

- willAnimateFirstHalfOfRotationToInterfaceOrientation:duration:

- willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration:

- didRotateFromInterfaceOrientation:

希望这对你也有帮助。

一个。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/601397

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档