如何在“搜索”中使用 UItableView 和 UINavigationController应用 ?最佳实践

发布于 2024-12-03 07:59:46 字数 667 浏览 0 评论 0原文

我想将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

江南烟雨〆相思醉 2024-12-10 07:59:46

您可以使用视图控制器作为根视图控制器来初始化导航控制器。然后隐藏导航栏(如果需要)。然后,您将添加 navigationController.view 作为子视图。这基本上看起来像原始的视图控制器。然后你可以pushViewController:animated:来推送结果视图控制器。

因此,例如在您的 AppDelegate 中(或在适当的视图控制器中):

为 UINavigationController 创建一个属性和 ivar,并在界面生成器中连接其出口。然后将搜索控制器设置为导航栏的根视图控制器,并将其添加为子视图。

MySearchViewController* searchController = [[MySearchViewController alloc] init];
self.myNavigationController = [[UINavigationController alloc] initWithRootController:searchController];
[searchController release];
self.myNavigationController.navigationBarHidden = YES;
[self.window addSubview:self.myNavigationController.view];
[self.window makeKeyAndVisible];

当然,在您的 searchController 中,您只需说:

ResultsViewController* myResultsViewController = [[MyResultsViewController alloc] init];
//You may want to create another init method and pass in some arguments like an array:
// [[MyResultsViewController alloc] initWithResults:results];

然后从结果视图控制器中推送视图控制器

//This is in your search controller class
[self.navigationController pushViewController:myResultsViewController Animated:YES];
[myResultsViewController release];

,然后将视图控制器从导航控制器视图控制器的堆栈中弹出。

//In results view controller perhaps in some IBAction for a back button:

-(IBAction)backButtonPressed:(id)sender
{

     [self.navigationController popViewControllerAnimated:YES];

}

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.

MySearchViewController* searchController = [[MySearchViewController alloc] init];
self.myNavigationController = [[UINavigationController alloc] initWithRootController:searchController];
[searchController release];
self.myNavigationController.navigationBarHidden = YES;
[self.window addSubview:self.myNavigationController.view];
[self.window makeKeyAndVisible];

Then of course in your searchController, you would simply say:

ResultsViewController* myResultsViewController = [[MyResultsViewController alloc] init];
//You may want to create another init method and pass in some arguments like an array:
// [[MyResultsViewController alloc] initWithResults:results];

then push the viewController

//This is in your search controller class
[self.navigationController pushViewController:myResultsViewController Animated:YES];
[myResultsViewController release];

from the results viewController, to get back you pop the view controller off of the navigationController view controller's stack.

//In results view controller perhaps in some IBAction for a back button:

-(IBAction)backButtonPressed:(id)sender
{

     [self.navigationController popViewControllerAnimated:YES];

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文