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 回答