问题
UISearchDisplayController
is deprecated in IOS8.0
, and recommended to use UISearchController
instead.
Then How to use the new **API**
to implement the flowing :
(from Beginning IOS7 Development Exploring the IOS SDK
)
UISearchBar *searchBar = [[UISearchBar alloc]
initWithFrame:CGRectMake(0, 0, 320, 44)];
tableView.tableHeaderView = searchBar;
searchContoller = [[UISearchDisplayController alloc]
initWithSearchBar:searchBar
contentsController:self];
searchController.delegate = self;
searchController.searchResultsDataSource = self;
You know, the API in UISearchController
is different, then how to do ?
回答1:
From APPLE DOCUMENTATION:
searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
searchController.searchResultsUpdater = self;
searchController.dimsBackgroundDuringPresentation = NO;
searchController.hidesNavigationBarDuringPresentation = NO;
searchController.searchBar.frame = CGRectMake(self.searchController.searchBar.frame.origin.x, self.searchController.searchBar.frame.origin.y, self.searchController.searchBar.frame.size.width, 44.0);
self.tableView.tableHeaderView = self.searchController.searchBar;
Check this SAMPLE PROJECT on UISearchController.
回答2:
Here is a sample project that replaces the UISearchDisplayController with UISearchController based off the Vea Software tutorial video found on youtube.
https://github.com/2015HuntMJ/UISearchController
NOTE: the above project uses swift
来源:https://stackoverflow.com/questions/27309993/uisearchdisplaycontroller-is-deprecated-in-ios8-0-then-how-to-init-it