简体   繁体   English

带有搜索栏的导航栏不会显示大标题

[英]Navigationbar with searchbar will not show large title

I have a UISplitViewController with a UINavigationController as the masterviewcontroller. 我有一个UISplitViewControllerUINavigationController作为masterviewcontroller。 This UINavigationController has a UICollectionViewController as its rootViewController. UINavigationController具有一个UICollectionViewController作为其rootViewController。 In the UICollectionViewController , I have set the following parameters: UICollectionViewController ,我设置了以下参数:

self.collectionView.scrollEnabled = YES;
self.collectionView.bounces = YES;
self.collectionView.alwaysBounceVertical = YES;
self.navigationController.navigationBar.prefersLargeTitles = YES;

UISearchController *sc = [[UISearchController alloc] initWithSearchResultsController:nil];
self.navigationItem.searchController = sc;

The UISearchBar does show up in the navigationBar, but when I launch the app the navbar is collapsed to the small title. UISearchBar确实显示在navigationBar中,但是当我启动该应用程序时,导航栏会折叠为小标题。 It's only when I drag the view downwards that the large title and the search bar appear. 只有当我向下拖动视图时,大标题和搜索栏才会出现。

Where I expect the view to launch like this 我希望这样的视图会在哪里发布

在此处输入图片说明

it actually launches like this 它实际上像这样启动

在此处输入图片说明

Any ideas what could be causing this? 任何想法可能是什么原因造成的?

Make sure you set preferLargeTitles to true in your UINavigationBar; 确保在UINavigationBar中将preferLargeTitles设置为true either in code or in the Storyboard file. 在代码中或在Storyboard文件中。

Put this in your viewDidLoad. 将其放在您的viewDidLoad中。

self.navigationController?.navigationBar.prefersLargeTitles = true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM