3

我在弹出窗口中嵌入了一个 UIViewController。这个控制器有两个子视图,一个 UINavigationBar 和一个 UITableView。我尝试实现新的搜索 API(因为 SearchDisplayControlled 在 iOS8 中已被弃用)。

当我点击搜索栏(显示两个范围)时,一切正常,导航栏仍然可见。但是当我开始在搜索栏中输入时,导航栏消失了,取而代之的是一个空白区域。我尝试添加self.searchController.hidesNavigationBarDuringPresentation = NO;updateSearchResultsForSearchController:方法,但没有得到任何结果。(注意控制器viewDidLoad defines self.definesPresentationContext = YES;

有什么想法可以随时显示导航吗?

4

2 回答 2

1

I was seeing the same effect - in my case setting the property in viewDidLoad in my view controller made the navigation bar stick around:

- (void)viewDidLoad {
    ...
    self.definesPresentationContext = YES;
    ...
}

When I'd previously set the same property from a class that was managing the search (initialized after -viewDidLoad had already been called on the VC), I saw the same behaviour of a blank nav bar that you describe.

于 2015-02-03T00:38:04.643 回答
1

这对我有用

self.navigationController.navigationBar.translucent = true;
于 2016-05-05T11:59:05.877 回答