Search: Show a search bar

This commit is contained in:
manuroe
2015-12-07 11:43:11 +01:00
parent be8017dedb
commit c969859593
2 changed files with 29 additions and 1 deletions
@@ -12,6 +12,9 @@
#import "RecentsDataSource.h"
@interface SearchViewController ()
{
UISearchBar* searchBar;
}
@end
@@ -21,6 +24,19 @@
{
[super viewDidLoad];
// Do any additional setup after loading the view.
searchBar = [[UISearchBar alloc] initWithFrame:self.navigationController.navigationBar.frame];
searchBar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
searchBar.showsCancelButton = YES;
searchBar.returnKeyType = UIReturnKeySearch;
self.navigationItem.leftBarButtonItem = [UIBarButtonItem new];
self.navigationItem.titleView = searchBar;
// This is a VC for searching. So, show the keyboard with the VC
dispatch_async(dispatch_get_main_queue(), ^{
[searchBar becomeFirstResponder];
});
}
- (void)didReceiveMemoryWarning
@@ -59,4 +75,16 @@
[self addMatrixSession:session];
}
#pragma mark - UISearchBarDelegate
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
return YES;
}
- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar
{
return YES;
}
@end