私はUISearchBarを(UISearchControllerを使用して)iOS8標準を設定し、UITableViewの上のUIViewControllerにプログラムで追加しています(現時点ではこれがiOS8でそれを行う唯一の方法だと信じています)私のviewDidLoadのように(他のすべてとは異なります) TableViewヘッダーに追加するチュートリアル)UITableViewをスクロールするときに私のものを固定したかった:
self.automaticallyAdjustsScrollViewInsets = NO;
UITableViewController *searchResultsController = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
searchResultsController.tableView.dataSource = self;
searchResultsController.tableView.delegate = self;
CGRect frame = [[UIScreen mainScreen] applicationFrame];
CGSize size = frame.size;
self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];
self.searchController.searchResultsUpdater = self;
self.searchController.searchBar.frame = CGRectMake(0, 60, size.width, 44.0);
self.definesPresentationContext = YES;
[self.view addSubview:self.searchController.searchBar];
私が抱えている問題は、検索フィールドをクリックすると、上に遷移して UINavigationBar の後ろに消えることです。これは、通常、UITableView のヘッダーでは発生しません。
これが起こらないようにする方法はありますか?ありがとうございました!