I'm wondering what solution is the best for the pull down action: Pull-To-Refresh vs. Pull-To-Search? What if I want to have both (search bar and refresh) like in the Mail app? Don't know what the approval in the app store does look like ...
How would you implement that with a UITableViewController
?
You can have both Pull-To-Refresh and Pull-To-Search in a UITableViewController quite easily.
Here's Pull to Refresh:
UIRefreshControl *refresh = [[UIRefreshControl alloc] init];
[self.tableView addSubview:refresh];
self.refreshControl = refresh;
To know when it has been 'pulled', add a target to the control:
[self.refreshControl addTarget:self action:@selector(refreshContent:) forControlEvents:UIControlEventValueChanged];
Here's "Pull-To-Search":
UISearchBar *searchBar = [[UISearchBar alloc] init];
UISearchDisplayController *searchController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
searchController.delegate = self;
searchController.searchResultsDataSource = self;
self.tableView.tableHeaderView = searchBar;
self.tableView.contentOffset = CGPointMake(0, CGRectGetHeight(searchBar.frame));
As you can see, Pull-To-Search is really just adding the searchBar as the tableHeaderView and offsetting the tableView a bit initially so the search bar isn't shown initially. That doesn't interfere with Pull-To-Refresh at all!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With