2
votes

I'm using a UITableViewController subclass in iOS 7.

Before I added the search bar as the table view's tableHearerView, the UIRefreshControl worked as I expected: I triggered beginRefreshing in viewDidLoad and I could see it spinning every time I entered this screen.

After I added the search bar, I can't see UIRefreshControl spinning when I enter this screen. Everything else seems to work fine, e.g pulling down will show the spinning UIRefreshControl.

Did I use the 2 widgets in right way? How to fix this issue so I can see the spinning like what I saw before adding the search bar?

Thanks a lot in advance!

1

1 Answers

1
votes

It looks like if you invoke the beginRefreshing method manually you also need to set the offset of the tableView manually.

Here is the solution in Objective-C:

[self.tableView setContentOffset:CGPointMake(0, -self.refreshControl.frame.size.height) animated:YES];

and here the solution in Swift:

self.tableView.setContentOffset(CGPointMake(0, -self.refreshControl!.frame.size.height), animated:true)