UISearchDisplayController "shouldReloadTableForSearchString return NO" reloads table

Posted by Jeena on Stack Overflow See other posts from Stack Overflow or by Jeena
Published on 2010-04-29T13:48:36Z Indexed on 2010/04/29 13:57 UTC
Read the original article Hit count: 596

Filed under:
|

Why does my UISearchDisplayController show "No results" even if the shouldReloadTableForSearchString method returns NO? Shouldn't it just do nothing and stay black? How can I prevent it from doing so?

#import "RootViewController.h"

#pragma mark Table view methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}


// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (tableView == self.searchDisplayController.searchResultsTableView) {
        return 0;
    }
    return 10;
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    // Configure the cell.
    cell.textLabel.text = [NSString stringWithFormat:@"row %d", indexPath.row];

    return cell;
}

#pragma mark SearchController stuff

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


- (void)dealloc {
    [super dealloc];
}


@end

© Stack Overflow or respective owner

Related posts about iphone

Related posts about cocoa-touch