Skip to content

Instantly share code, notes, and snippets.

@oliverfoggin oliverfoggin/gist:10024117
Last active Aug 29, 2015

Embed
What would you like to do?
Failing UISearchDisplayController
#import "UserSearchViewController.h"
@interface UserSearchViewController () <UISearchBarDelegate, UISearchDisplayDelegate>
@end
@implementation UserSearchViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.searchDisplayController.displaysSearchBarInNavigationBar = YES;
}
// create 10 rows that display the row number.
// no data source atm for the minimum failing test
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 10;
}
// just display the row number
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.textLabel.text = [NSString stringWithFormat:@"%ld", (long)indexPath.row];
return cell;
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.