平成30年2月27〜28日(火曜日)
対策:searchDisplayController’ is deprecated: first deprecated in iOS 8.0
対策完了。
基本は、ui-searchcontroller-objcによる。
概要は以下。
①
.m
@property (nonatomic, strong) UISearchController *searchController;
②
MasterViewController.m
Delegate追加
@interface MasterViewController ()
③
viewDidLoadの最後(最初に置くと、error)
[self initializeSearchController];
④
updateSearchResultsForSearchControllerの設定
// フィルタ作業後tableViewをreload
filterContentForSearchText
[((UITableViewController *)self.searchController.searchResultsController).tableView reloadData];
⑤
prepareForSegue
if ( self.searchController.active ) {}による切り替え
⑥
サーチバー設定
[self.searchController.searchBar setSearchBarStyle:UISearchBarStyleMinimal];
⑦
iOS 11.0
//add the UISearchController's search bar to the header of this table
//self.tableView.tableHeaderView = self.searchController.searchBar;
if ([self.navigationItem respondsToSelector:@selector(setSearchController:)]) {
// For iOS 11 and later, we place the search bar in the navigation bar.
if (@available(iOS 11.0, *)) {
self.navigationController.navigationBar.prefersLargeTitles = NO;
} else {
// Fallback on earlier versions
}
if (@available(iOS 11.0, *)) {
self.navigationItem.searchController = self.searchController;
} else {
// Fallback on earlier versions
}
// We want the search bar visible all the time.
if (@available(iOS 11.0, *)) {
// 今回はYES(好みか)
self.navigationItem.hidesSearchBarWhenScrolling = YES;
} else {
// Fallback on earlier versions
}
}
else {
// For iOS 10 and earlier, we place the search bar in the table view's header.
self.tableView.tableHeaderView = self.searchController.searchBar;
}