dongfangchun
//在ViewDidLoad里面如下代码

self.searchViewController = [[UISearchController alloc]initWithSearchResultsController:nil]; self.searchViewController.active = NO; self.searchViewController.dimsBackgroundDuringPresentation = NO; self.searchViewController.hidesNavigationBarDuringPresentation = YES; [self.searchViewController.searchBar sizeToFit]; self.searchViewController.searchBar.barTintColor = kALittleGray; //设置显示搜索结果的控制器 self.searchViewController.searchResultsUpdater = self; //协议(UISearchResultsUpdating) self.searchViewController.delegate = self; self.tableView.tableHeaderView = self.searchViewController.searchBar; self.searchViewController.searchBar.keyboardType = UIKeyboardAppearanceDefault; self.searchViewController.searchBar.placeholder = @"请输入城市关键字";

遵守协议:

UISearchBarDelegate,UISearchControllerDelegate,UISearchResultsUpdating

 

 

 

 

#pragma mark - other delegate

- (void)updateSearchResultsForSearchController:(UISearchController *)searchController{

    

   

}

 

- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar

{

    return YES;

}

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
  • 2021-11-03
  • 2021-09-29
  • 2021-10-05
猜你喜欢
  • 2022-12-23
  • 2021-08-21
  • 2021-11-03
  • 2022-02-08
  • 2022-12-23
  • 2021-11-03
  • 2022-12-23
相关资源
相似解决方案