正确显示UISearchController的搜索结果

时间:2018-07-21 13:23:36

标签: ios swift uisearchcontroller

我有以下情况:

带有导航栏的TableViewController(我们称其为TVC1)。 在TVC1的viewDidLoad中,我创建了一个UISearchController(称为searchController)并将其设置为导航项的搜索控制器

navigationItem.searchController = searchController

然后我还有第二个TableViewController(TVC2),应该显示搜索结果。

UISearchController(searchResultsController: tvc2)

如果我现在使用搜索栏,我可以看到结果表,但它会填满整个屏幕,而不是替换tvc1的表。 因此,即使搜索栏也不再可见。

可能是什么问题?

1 个答案:

答案 0 :(得分:0)

刚刚找到了答案:)
在TVC1中,必须设置

definesPresentationContext = true
相关问题