UITeBarController状态栏问题中的UISearchController

Ven*_*Rao 6 uikit ios

我一直遇到状态栏和标签栏的问题.

在此输入图像描述

这是我的代码:

self.searchResultsController = [BZDashboardSearchResultsController new];

self.searchController = [[UISearchController alloc] initWithSearchResultsController:self.searchResultsController];
self.searchController.hidesBottomBarWhenPushed = YES;
self.searchController.searchResultsUpdater = self;
self.searchController.hidesNavigationBarDuringPresentation = YES;
self.definesPresentationContext = YES;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.view.backgroundColor = [UIColor whiteColor];

self.searchController.delegate = self;
self.searchController.searchBar.delegate = self;

[self presentViewController:self.searchController
                   animated:YES
                 completion:nil];
Run Code Online (Sandbox Code Playgroud)

我想隐藏标签栏,将搜索栏放在状态栏下.我的视图控制器层次结构如下所示:

UITabBarController
   --UINavigationController
       ---View Controller where the above code is executed.
Run Code Online (Sandbox Code Playgroud)

在我的app委托中,我将我的UITabBarController子类设置为根视图控制器:

self.window.rootViewController = tabBarViewController;
Run Code Online (Sandbox Code Playgroud)

子类的init方法是这样的:

-(instancetype)init {
  self = [super init];

  if (self) {
    UINavigationController *workspaceNavigationController = [[UINavigationController alloc] initWithRootViewController:self.workspaceController];

    self.userProfileViewController.showLogoutButton = YES;
    UINavigationController *userProfileNavigationController = [[UINavigationController alloc] initWithRootViewController:self.userProfileViewController];

    self.viewControllers = @[workspaceNavigationController, userProfileNavigationController];
  }

  return self;
}
Run Code Online (Sandbox Code Playgroud)

self.workspaceController在其导航栏中有一个搜索按钮,用于预设UiSearchController的代码.