chenzhongpu
chenzhongpu

Reputation: 6871

UISearchDisplayController is deprecated in IOS8.0, then how to init it?

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 ?

Upvotes: 0

Views: 4503

Answers (2)

MasterProgrammer200
MasterProgrammer200

Reputation: 1021

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

Upvotes: 0

Rumin
Rumin

Reputation: 3790

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.

Upvotes: 2

Related Questions