Delegate Methods Not Firing on Search Results Table
- by Slinky
All,
I have a UITableView w/detail, with a Search bar, created from code. Works fine on selected items except it doesn't work when an item is clicked from the search results; no delegate methods fire. Never seen this type of behavior before so I don't know where the issue lies.
I get the same behavior with standard table cells as well as custom table cells.
Appreciate any guidance on this and thanks.
Just Hangs Here
//ViewController.h
@interface SongsViewController : UITableViewController <UISearchBarDelegate,UISearchDisplayDelegate>
{
NSMutableArray *searchData;
UISearchBar *searchBar;
UISearchDisplayController *searchDisplayController;
UITableViewCell *customSongCell;
}
//ViewController.m
-(void)viewDidLoad
{
[super viewDidLoad];
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, screenWidth, 88)];
[searchBar setShowsScopeBar:YES];
[searchBar setScopeButtonTitles:[[NSArray alloc] initWithObjects:@"Title",@"Style", nil]];
searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
searchDisplayController.delegate = self;
searchDisplayController.searchResultsDataSource = self;
self.tableView.tableHeaderView = searchBar;
//Load custom table cell
UINib *songCellNib = [UINib nibWithNibName:@"SongItem" bundle:nil];
//Register this nib, which contains the cell
[[self tableView] registerNib:songCellNib forCellReuseIdentifier:@"SongItemCell"];
// create a filtered list that will contain products for the search results table.
SongStore *ps = [SongStore defaultStore];
NSArray *songObjects = [ps allSongs];
self.filteredListContent = [NSMutableArray arrayWithCapacity: [songObjects count]];
self.masterSongArr = [[NSMutableArray alloc] initWithArray:[ps allSongs]];
[self refreshData];
[self.tableView reloadData];
self.tableView.scrollEnabled = YES;
}