当UISearchController处于活动状态并选择了新选项卡时,UITableView将消失 [英] UITableView disappears when UISearchController is active and a new tab is selected

查看:105
本文介绍了当UISearchController处于活动状态并选择了新选项卡时,UITableView将消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,如果标题不清楚,总结一下很难。

Sorry if the title isn't that clear, found it tricky to summarise.

使用Xcode 6 Beta 4,目标iOS 8:

Using Xcode 6 Beta 4, target iOS 8:

我有一个UITabBarController,它的一个控制器是一个UITableViewController(TVC)。这个TVC有一个searchController属性,它是新的UISearchController,它正在取代UISearchDisplayController。像这样初始化它(我会把它添加到我的故事板但是右下角的对象库中的searchController仍然是一个UISearchDisplayController - 我应该为此提交雷达吗?):

I have a UITabBarController and one of its controllers is a UITableViewController (TVC). This TVC has a searchController property which is the new UISearchController which is replacing UISearchDisplayController. Initialising it like so (I would have just added it to my storyboard but the searchController in the object library down in the bottom right is still a UISearchDisplayController - should I file a radar for this?):

self.searchController = [[UISearchController alloc]initWithSearchResultsController:nil];
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.searchResultsUpdater = self;
self.searchController.delegate = self;
self.searchController.searchBar.frame = CGRectMake(0, 0, 320, 44);
self.tableView.tableHeaderView = self.searchController.searchBar;

如果searchBar是第一响应者,那就明白了:

Getting to the point, if the searchBar is first responder:

然后在tabBar上选择了另一个标签,然后你回来了:

and then another tab is selected on the tabBar, and then you come back:

我不知道为什么会这样?或许UISearchController错误?或者是文档没有告诉我我应该做的事情(目前缺乏细节)。

I have no idea why this is happening? UISearchController bug perhaps? Or is the documentation not telling me something that I should be doing (it lacks detail at the moment).

推荐答案

我得到了我的 UISearchController 由于我在GitHub上找到的这个示例项目

在信用到期时给予信用,我认为dempseyatgithub做得非常出色,可以让每个人都可以使用用作参考项目。谢谢!

Giving credit where credit is due, I think dempseyatgithub has done a fantastic job of making this available for everyone to use as a reference project. Thanks!

这篇关于当UISearchController处于活动状态并选择了新选项卡时,UITableView将消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆