旋转时调整UINavigationBar的大小 [英] Resizing UINavigationBar on rotation

查看:184
本文介绍了旋转时调整UINavigationBar的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个处理UIView的UIViewController子类.视图控制器以模态显示(从屏幕底部向上滑动).在视图的顶部,我添加了一个导航栏.请注意,此栏未由导航控制器处理.

I have a subclass of UIViewController which handles a UIView. The viewcontroller is presented modally (it slides up from the bottom of the screen). At the top of the view, i have added a navigation bar. Note that this bar is not handled by a navigation controller.

当视图旋转到横向时,我想使导航栏的高度缩小(类似于由UINavigationController处理时的行为).但是,我无法在IB中将其自动调整大小蒙版设置为灵活的高度,而在代码中这样做会导致导航栏完全消失.

I want to get the navbar to shrink in height when the view rotates to landscape (similar to how it behaves when it is handled by a UINavigationController). However, I can't set its autoresizing mask to flexible height in IB, and doing so in code causes the navbar to disappear completely.

有没有办法做到这一点? UINavigationController如何完成?

Is there a way to do this? How is it done by the UINavigationController?

P.S.我宁愿不必诉诸缩放转换,因为这会使标题中的文本弄乱.

P.S. I would prefer not having to resort to a scaling transform, since this would mess up the text in the title.

我在一点帮助下解决了问题,请阅读下面的答案.

I solved it with a little help, read the answer posted below.

推荐答案

我找到了解决方案,事后看来,我感到很愚蠢.我只需要在导航栏的自动调整大小蒙版中包含灵活的底部边距即可.功劳归功于该线程中的用户RayNewbie,这为我指出了解决方案:

I found the solution, and in hindsight i feel rather stupid. I just had to include flexible bottom margin in the navbar's autoresize mask. Credit is due to user RayNewbie in this thread, which pointed me to the solution:

http://discussions.apple.com/thread.jspa?messageID=8295525

这篇关于旋转时调整UINavigationBar的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆