1

ここで少し問題があります。テキストの入力を開始すると、検索バーが検索するのはなぜですか? コードは次のとおりです。

     - (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar {
         [searchBar setShowsCancelButton:YES animated:YES];
         self.theTableView.allowsSelection = NO;
         self.theTableView.scrollEnabled = NO;
         [theTableView setRowHeight:110];
     }

     - (void)searchDisplayController:(UISearchDisplayController *)controller willShowSearchResultsTableView:(UITableView *)tableView {
         [tableView setRowHeight:[[self theTableView] rowHeight]];
         tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
         [self.tableData removeAllObjects];
     }

     - (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
         searchBar.text=@"";

         [searchBar setShowsCancelButton:NO animated:YES];
         [searchBar resignFirstResponder];
         self.theTableView.allowsSelection = YES;
         self.theTableView.scrollEnabled = YES;
     }

     - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {

       // all the function to search

     }
4

1 に答える 1

1

実装searchDisplayController:shouldReloadTableForSearchString:してNOを返します。これにより、検索中のデータの自動再読み込みが防止されます。

于 2011-03-10T18:49:24.357 に答える