当UISearchBar变为活动状态时,如何隐藏UIRefreshControl?

时间:2014-09-09 17:00:23

标签: ios uisearchdisplaycontroller uirefreshcontrol

我有一个tableview,支持下拉刷新和搜索(单独)。如果我下拉刷新并立即单击搜索栏,我该如何隐藏refreshControl?

2 个答案:

答案 0 :(得分:3)

我找到的最佳解决方案是在搜索栏处于活动状态时完全禁用刷新。

@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;
 }

答案 1 :(得分:2)

@Bejibun让我得到了基于this comment的答案。只需将UITablevies偏移设置为(0 - refresh_control_height)

所以..

self.tableView.contentOffset = CGPointMake(0, 0 - self.refreshControl.frame.size.height);
相关问题