とても特別なお願いがあります。同じシナリオではないため、チュートリアルや既に尋ねられた質問はありませんでした。すべてのコードを再プログラミングせずに既存のアプリを強化したいので、特別です。
プログラムで UISearchbar を追加したい。検索バーは、プログラムでも追加される UITableView に追加する必要があります。
これはすべて、通常の UIViewController で行われます。
私の現在のアプローチでは検索バーが表示されますが、UITableView 内では検索されません。単に何も起こりません。
私は何を間違っていますか?
myTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
searchBar.delegate = self;
myTableView.tableHeaderView = searchBar;
UISearchDisplayController *searchController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
searchController.searchResultsDataSource = self;
searchController.searchResultsDelegate = self;
searchController.delegate = self;
myTableView.dataSource = self;
myTableView.delegate = self;
[self.view addSubview:myTableView];