How to hide UIRefreshControl when UISearchBar becomes active?

I have a table view that supports pull down for refresh and search (separately). If I downgrade to refresh and hit the search bar right away, how can I hide refreshControl?

+3


source to share


2 answers


@Bejibun led me to an answer to this comment . You just need to set the table offset to (0 - refresh_control_height).



so .. self.tableView.contentOffset = CGPointMake (0, 0 - self.refreshControl.frame.size.height);

+2


source


The best solution I've found so far is to turn off the update completely while the search bar is active.



@property(nonatomic, strong) UIRefreshControl *refreshControl;
....

- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
    // Disable refresh control
    self.refreshControl = self.tableViewController.refreshControl;
    self.tableViewController.refreshControl = nil;
    return YES;
}

- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar
{   
    //Restore refresh control
    self.tableViewController.refreshControl = self.refreshControl;
 }

      

+2


source







All Articles