gpt4 book ai didi

ios - 当我打开搜索栏时,导航栏隐藏了

转载 作者:可可西里 更新时间:2023-11-01 04:20:30 25 4
gpt4 key购买 nike

我的 导航栏 中嵌入了一个 UISearchController,当我单击它时,整个导航栏会离开屏幕,直到我按下屏幕上的另一个区域,然后它回来了。这是 a link到视频。 (视频可能已经上传,请稍等片刻,链接有效)

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

最佳答案

需要添加以下内容

self.searchController.hidesNavigationBarDuringPresentation = NO;

停止 UISearchController 在激活时隐藏导航栏(ref docs link)。

关于ios - 当我打开搜索栏时,导航栏隐藏了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34024056/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com