如何显示“模态”在标签栏界面*中查看(控制器)而不隐藏标签栏
我想实现一个“模态”视图,就像 iPad 上 AppStore 的“搜索”视图一样。
显示时,它应该:
- 仍然显示选项卡栏。选择任何项目都会让您正常看到它们的视图。
- 没有突出显示选项卡栏项目(因为搜索视图是“模态”)。
对于现有的 API,我最接近的是:
- 在“搜索”视图控制器上,设置
UIModalPresentationCurrentContext
模式呈现样式。 - 从标签栏控制器内的活动视图控制器(而不是从标签栏控制器本身)显示“搜索”视图控制器模式。
然而,这似乎不是正确的路径:
- 视图控制器显示在状态栏下方。我可以通过
-[UIViewController viewDidAppear:]
解决这个问题,但是当更改设备的方向时,这会导致各种绘图问题,并且控制器再次将自身隐藏在状态栏下方。 - 选项卡栏项目仍然突出显示。
I want to implement a ‘modal’ view like the ‘search’ view of the AppStore on the iPad.
When shown, it should:
- Still show the tab bar. Selecting any of the items should take you to their view as normal.
- No tab bar item is highlighted (because the search view is ‘modal’).
The closest I’ve come, with existing APIs, is:
- On the ‘search’ view controller, set the
UIModalPresentationCurrentContext
modal presentation style. - Show ‘search’ view controller modal from the active view controller inside the tab bar controller (not from the tab bar controller itself).
However, this does not seem to be the right path:
- View controller is shown underneath the status bar. I can work around that from
-[UIViewController viewDidAppear:]
, but when changing the orientation of the device, this leads to all sorts of drawing issues and the controller, again, tucks itself underneath the status bar. - Tab bar item is still highlighted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要继续显示搜索栏,只需修剪模式视图的高度,使其不会覆盖选项卡栏。
对于方向更改,您只需通过更改视图大小并确保模式视图始终位于所有视图的前面来处理。您可以通过编程方式修改该视图的框架和内容,或者您可以为您想要支持的方向创建笔尖,并在其更改时加载它们。另请注意,如果您确实以编程方式更改视图的框架,您可能还需要调整字段的大小/重新定位。
为了处理标签栏,您应该能够关闭突出显示的项目。因此,当您弹出模式时,还要确保关闭突出显示的项目。如果您想从模式视图与工具栏进行交互,您可以使用委托来实现,传递父视图的实例(或者只是访问父视图......我认为您可以免费获得)
to keep showing the search bar just trim the modal view's hight so that it doesn't cover the tab bar.
For orientation changes, you just need to handle that by changing the view size and making sure the modal view is always brought to the front of all the views. You can modify that view's frame and contents programmatically or you can just create nibs for the orientations you want to support and load them up when it changes. Also note if you do change the view's frame programmatically you will probably need to resize/reposition fields as well.
For dealing with the tab bar, you should be able to turn off the highlighted item. So when you pop up the modal also make sure to turn off the highlighted item. If you want to interact with the toolbar from the modal view you can do that with delegates, passing an instance of the parent view (or just accessing parent view... I think you get that for free)