Skip to content

Instantly share code, notes, and snippets.

@oliverfoggin
Last active August 29, 2015 13:58
Show Gist options
  • Save oliverfoggin/10024117 to your computer and use it in GitHub Desktop.
Save oliverfoggin/10024117 to your computer and use it in GitHub Desktop.
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