阻止 UIToolbar 在横向方向上消失 - iPad
不确定为什么会发生这种情况或如何阻止它,详细信息 viewcontroller
上的 UIToolBar
仅在纵向视图期间可见。我希望它在所有方向都可见。我该怎么做?谢谢。
Not sure why this happens or how to stop it, my UIToolBar
on the details viewcontroller
is only visible during portrait view. I want it visible at all orientations. How do I do that? Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我遇到了同样的问题,只需将 UIToolBar 拖到我的视图上并将其停靠在窗口顶部即可。它以横向显示,但不以纵向显示。 Interface Builder - 至少是嵌入在 Xcode 4 中的那个 - 似乎没有对调整大小蒙版做正确的事情。
虽然 Kshitiz 的上述答案可行,但它有一些缺陷。根据编码,它不支持所有四个方向。更重要的是,它与分辨率无关。
enamrik 的评论中简要描述了更好的解决方案,因此应归功于他/她。步骤如下:
I encountered the same problem by just dragging a UIToolBar on to my view and docking it on the top of the window. It showed up in landscape but not portrait. Interface Builder - at least the one embedded in Xcode 4 - doesn't seem to do the right thing with the resize masks.
While Kshitiz's answer above will work, it has a couple of flaws. As coded, it does not support all four orientations. More importantly, it's not resolution independent.
A better solution is briefly described in enamrik's comment, so credit should go to him/her. Here are the steps:
在你的视图控制器的这个功能中重置视图框架兄弟
和你的工具栏框架
祝你好运
in your this function of view controller reset view frame bro
and your tool bar frame too
good luck
当我以编程方式添加 UIPickerView 并为 PickerView 添加 UIToolBar 时,遇到了同样的问题。只需要为 UIPickerView 添加
[.flexibleWidth,.flexibleHeight]
即可。例如:-然后添加
Faced the same problem when I add UIPickerView programmatically and add UIToolBar for the PickerView. Just need to add
[.flexibleWidth,.flexibleHeight]
for the UIPickerView. eg:-And then add