presentmodalviewcontroller - 如何不让它覆盖整个屏幕?
我的工具栏上有一个选项卡栏和一个搜索按钮。因此,现在每当用户单击搜索时,我都希望出现一个视图(presenetmodalviewcontroller),但是当前的模态视图控制器覆盖整个屏幕,有什么方法可以使其仅覆盖当前视图(即当前选项卡栏中的视图)?现在我怎样才能做到这一点?
谢谢, 图沙尔·丘塔尼
I have a tab bar and a search button on its toolbar. So now whenever the user clicks the search i would like a view to come up (presenetmodalviewcontroller) but present modal view controller covers entire screen is there any way that it covers only the present view (ie view in the current tab bar)? now how can I accomplish this?
thanks,
Tushar Chutani
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据定义,模态视图控制器旨在“中断”应用程序的当前流程以进行其他操作(请求用户/通行证、要求联系人发送电子邮件等)。您可以在 视图控制器编程指南< /a>.
您最好在当前选项卡内使用导航堆栈 (
UINavigationController
) 来处理必须呈现给用户的其他 viewController。这是关于如何在标签栏应用程序中放置导航控制器的另一个堆栈溢出问题 。使用导航堆栈,您可以推送视图控制器 (pushViewController:animated:
),并管理单个选项卡项的不定深度的 viewController。By definition, a modal view controller is meant to "interrupt" the current flow of an application for something else (requesting a user/pass, asking for a contact to send an email, etc). You can read more about this in the View Controller Programming Guide.
You are better off using a navigation stack (
UINavigationController
) inside the current tab to handle other viewControllers that must be presented to the user. Here's another stack overflow question on how to place navigation controllers in a tab bar application. With a navigation stack, you can push view controllers (pushViewController:animated:
), and manage an indefinite depth of viewControllers for a single tab item.一种选择是让选项卡栏中的视图位于 NavigationController 中。然后,您可以将ViewController 压入堆栈,而不是presentModalViewController。这将使底部的 tabBar 可见,并且允许您向后导航。
然而,这确实在顶部添加了一个导航栏。不确定这是否是您的应用程序的问题。
One option is for the view that's inside the tabbar to be within a NavigationController. Then , instead of presentModalViewController, you would pushViewController onto the stack. That would leave the tabBar at the bottom visible and it allows you to navigate back.
That does however add a navigationBar to the top. Not sure if that's a problem for your app.
所以这就是我能够做的不是最好的代码但它有效的我所做的几乎就是将子视图添加到 uiimageview (应该使用 UIWindow 但谁在乎呢?)
So this is how I was able to do not the best code but it works What I have pretty much done is addsubview to a uiimageview (should have used UIWindow but who cares?)