UITeBarController状态栏问题中的UISearchController

时间:2015-10-02 19:39:20

标签: ios uikit

我在状态栏和标签栏中遇到此问题。

enter image description here

这是我的代码:

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];

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

UITabBarController
   --UINavigationController
       ---View Controller where the above code is executed.

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

self.window.rootViewController = tabBarViewController;

子类的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;
}

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

0 个答案:

没有答案