当前位置:  开发笔记 > 编程语言 > 正文

打开搜索栏时导航栏正在隐藏

如何解决《打开搜索栏时导航栏正在隐藏》经验,为你挑选了1个好方法。

我有一个UISearchController嵌入我的Navigation Bar,当我点击它,整个导航栏离开屏幕,直到我按下屏幕上的另一个区域然后它回来.这是视频的链接.(视频mightent已上传,所以给它一些时间,链接确实有效)

    self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
    self.searchController.dimsBackgroundDuringPresentation = NO;
    // Use the current view controller to update the search results.
    self.searchController.searchResultsUpdater = self;
    //Setting Style
    self.searchController.searchBar.barStyle = UIBarStyleBlack;
    self.searchController.searchBar.barTintColor = [UIColor colorWithRed:49.0/255.0 green:49.0/255.0 blue:61.0/255.0 alpha:1.0];
    self.searchController.searchBar.backgroundImage = [UIImage imageNamed:@"BG"];
    self.searchController.searchBar.placeholder = @"Search Artists, Songs, Albums etc.";
    self.searchController.searchBar.keyboardAppearance = UIKeyboardAppearanceDark;
    [self.searchController.searchBar sizeToFit];
    self.definesPresentationContext = YES;
    self.searchController.searchBar.tintColor = self.view.window.tintColor;
    [self.searchController.searchBar setTintColor:[UIColor colorWithRed:(226.0/255.0) green:(56.0/255.0) blue:(83.0/255.0) alpha:(1.0)]];
    self.searchController.searchBar.delegate = self;
    self.navigationItem.titleView = self.searchController.searchBar;
}

- (void)updateSearchResultsForSearchController:(UISearchController *)searchController{
    NSString *searchString = searchController.searchBar.text;
    NSLog(@"You searched for %@", searchString);
    [searchResultsTableView reloadData];
 }

-(void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar{
    [self.view addSubview:searchResultsTableView];
}

AndrewR.. 11

您需要添加以下内容

self.searchController.hidesNavigationBarDuringPresentation = NO;

停止UISearchController在激活时隐藏导航栏(参考文档链接).



1> AndrewR..:

您需要添加以下内容

self.searchController.hidesNavigationBarDuringPresentation = NO;

停止UISearchController在激活时隐藏导航栏(参考文档链接).

推荐阅读
Life一切安好
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有