1

こんにちは、もう一度検索したときに SearchBar がテーブル ビュー セルを除外しない理由を知りたいですか? 最初のセルの上に別のセルを追加するだけです。

        - (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;
        }


        - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {
            return NO;
        }

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

            // All functions goes here and bla bla bla

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

            //Remove tudo da table e recarrega

            [self.tableData removeAllObjects];
            [theTableView reloadData];

            [[[self searchDisplayController] searchResultsTableView] performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];

        }

ありがとう

4

1 に答える 1

0

2 つのテーブルビューと 2 つのフェッチ コントローラーでここに投稿されたテクニックを使用してください。少し複雑ですが、必要のないコードの一部を削除できます。

于 2011-04-01T10:45:43.023 に答える