【发布时间】:2015-08-18 18:12:45
【问题描述】:
我有一个 tabbarcontroller,它位于 uinavigationcontroller 内部,我试图在其中一个选项卡上的 tableviewheader 中放置一个搜索栏。我能够在导航控制器上的任何屏幕上成功使用下面的代码,但是当视图位于 tabbarcontroller 上时,搜索不会响应触摸。我可以成功地将其设置为在代码中处于活动状态,但我也需要触摸才能工作。
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.searchBar.scopeButtonTitles = @[@"SEARCH"];
[self.searchController.searchBar setPlaceholder:@"SEARCH"];
self.searchController.searchBar.delegate = self;
self.searchController.delegate = self;
self.searchController.searchBar.backgroundColor = [UIColor colorWithRed:0.843 green:0.843 blue:0.843 alpha:1];
self.searchController.searchBar.tintColor = [UIColor blackColor];
self.myTableView.tableHeaderView = self.searchController.searchBar;
self.definesPresentationContext = YES;
[self.searchController.searchBar sizeToFit];
【问题讨论】:
标签: ios iphone uitableview ipad uisearchcontroller