Objective C:方向变化的自适应工具栏
当我更改 iPad 的方向时,我的工具栏出现问题。
我将笔尖文件设置为横向,一切都很好,但是当我将其转换为纵向时,我的工具栏仍然具有横向的宽度。
如何使我的工具栏适应方向更改为纵向?
景观:
肖像:
谢谢!
I am having a problem with my toolbar when i change the orientation of my iPad.
i set my nib file into landscape and everything is all right but when i turned it to portrait my toolbar still has the width from the landscape orientation.
how will i make my toolbar adaptive to the orientation change to portrait?
Landscape:
Portrait:
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试将
UIViewAutoresizingFlexibleWidth
添加到工具栏autoresizingMask
中,如下所示:或者,如果您在 Interface Builder 中执行此操作,请确保选择此水平栏(也可以选择其他水平栏,这很好):
更多内容来自
UIView
类参考< /a> 关于autoresizingMask
:Try adding
UIViewAutoresizingFlexibleWidth
to the toolbarautoresizingMask
like so:Or, if your doing this in the Interface Builder, make sure this horizontal bar is selected (others may be selected as well, which is fine):
More from the
UIView
Class Reference aboutautoresizingMask
:除了调整工具栏的灵活宽度之外,您还可以创建 2 个工具栏项目数组。一张用于肖像,一张用于风景。幸运的是,您只需创建工具栏项一次,然后将它们添加到适当的数组中即可。
然后,在方向更改期间,您可以将工具栏的项目数组设置为适当的数组。
祝你好运
In addition to adjusting the flexible width of your toolbar you could create 2 arrays of toolbar items. One for portrait and one for landscape. Fortunately you only have to create the toolbar items once and just add them to the appropriate array(s).
Then during the orientation change you can set the toolbar's items array to the appropriate one.
Good Luck