如何在“搜索”中使用 UItableView 和 UINavigationController应用 ?最佳实践
我想将 UITableView 和 UINaviationController 结合在一个应用程序中,但作为新手,我见过的大多数应用程序只是将您直接发送到结果视图(UITableView)。但是,我想“普通”搜索应用程序不会假设您在第一个屏幕上有结果。第一个屏幕上应该有一个搜索表单,其中包含输入字段和一个触发搜索过程并显示一些结果和导航的按钮。
所以,我只是想在我的应用程序中复制这种正常行为。我已经制作了搜索表单(当然,上面没有显示导航)和一个名为“ListingViewController”的独立视图及其相关视图并包含 UITableView,我认为我应该在其中添加导航...下一个想法将是制作一个 DetailViewController 以及可能的 ListingMapController 以在 GoogleMap 中显示列表。
那么,我遇到的问题是如何添加这个导航控制器?
有人建议我将其添加到 SearchViewController 委托中...... 但我当然不想在搜索表单上进行导航...
有些人建议我以模式方式打开导航控制器... 但是,我还计划添加一个选项卡栏,以允许用户查看其他信息(如“关于”等),并且使用模态导航控制器,我不知道他们是否仍会看到底部选项卡栏...
您有什么建议吗?特别是为了避免我的应用程序被 Apple 拒绝,
请提前感谢
Stephane 的阅读和帮助!
I would like to combine UITableView and UINaviationController in an app but as a newbie most apps I've seen just send you straight to the results view (UITableView). But, I guess a "normal" search application does not assume you have the results on the first screen. There should be a search form on first screen with input fields and a button that triggers the search process and show some results and navigation.
So, I'm just trying to replicate this normal behaviour in my app. I've already made the search form (no navigation shown on it, of course) and a seperated View called "ListingViewController" with its related View and containing a UITableView and where I think I should add the Navigation...The next idea will be to make a DetailViewController and possibly and ListingMapController to show the listing in a GoogleMap.
So, where I'm stuck at is how to add this Navigation Controller ?
Some suggested me to add it in the SearchViewController delegate...
But I don't want a navigation on search form of course...
Some suggested me to open the Navigation controller modally...
But, I"m also planning at adding a Tab Bar to allow user to see other informations (like About,etc...) and with a modal Nav controller I don't know if they will still see the bottom Tabbar...
Any suggestions? What do you think is of best practices especially to avoid my app of being rejected by Apple?
Thx in advance for reading and helping!
Stephane
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用视图控制器作为根视图控制器来初始化导航控制器。然后隐藏导航栏(如果需要)。然后,您将添加 navigationController.view 作为子视图。这基本上看起来像原始的视图控制器。然后你可以pushViewController:animated:来推送结果视图控制器。
因此,例如在您的 AppDelegate 中(或在适当的视图控制器中):
为 UINavigationController 创建一个属性和 ivar,并在界面生成器中连接其出口。然后将搜索控制器设置为导航栏的根视图控制器,并将其添加为子视图。
当然,在您的 searchController 中,您只需说:
然后从结果视图控制器中推送视图控制器
,然后将视图控制器从导航控制器视图控制器的堆栈中弹出。
You could init the navigationController with your View Controller as the root view Controller. Then hide the navigationBar (if you need to). You would then add the navigationController.view as the subview. This will basically look like the original view controller. Then you can pushViewController: animated: to push the results view Controller.
So, for example in your AppDelegate (or in the proper view controller):
Create a property and ivar for a UINavigationController and hook up its outlets in interface builder. Then set your search controller as the root view controller for the nav bar, and add it as a subview.
Then of course in your searchController, you would simply say:
then push the viewController
from the results viewController, to get back you pop the view controller off of the navigationController view controller's stack.