【发布时间】:2011-03-09 07:09:58
【问题描述】:
不知道为什么会发生这种情况或如何阻止它,我的UIToolBar 详细信息viewcontroller 仅在纵向视图中可见。我希望它在所有方向都可见。我怎么做?谢谢。
【问题讨论】:
标签: objective-c ipad orientation uisplitviewcontroller uitoolbar
不知道为什么会发生这种情况或如何阻止它,我的UIToolBar 详细信息viewcontroller 仅在纵向视图中可见。我希望它在所有方向都可见。我怎么做?谢谢。
【问题讨论】:
标签: objective-c ipad orientation uisplitviewcontroller uitoolbar
我只是将 UIToolBar 拖到我的视图并将其停靠在窗口顶部时遇到了同样的问题。它出现在横向而不是纵向。 Interface Builder - 至少是嵌入在 Xcode 4 中的那个 - 似乎没有对调整大小掩码做正确的事情。
虽然上面 Kshitiz 的答案可行,但它有几个缺陷。按照编码,它不支持所有四个方向。更重要的是,它与分辨率无关。
enamrik 的评论中简要描述了一个更好的解决方案,因此应该归功于他/她。步骤如下:
【讨论】:
在您的视图控制器的此功能中重置视图框架兄弟
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Override to allow orientations other than the default portrait orientation.
if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation==UIInterfaceOrientationLandscapeRight) {
self.view.frame = CGRectMake(0, 0, 703,768);
} else {
self.view.frame = CGRectMake(0, 0, 768, 1024);
}
return YES;
}
还有你的工具栏框架 祝你好运
【讨论】:
当我以编程方式添加 UIPickerView 并为 PickerView 添加 UIToolBar 时遇到了同样的问题。只需为 UIPickerView 添加[.flexibleWidth,.flexibleHeight]。例如:-
let statTypePicker = UIPickerView()
然后添加
self.statTypePicker.autoresizingMask = [.flexibleWidth,.flexibleHeight]
【讨论】: