0

In my UIViewController, I have a UITableView as one of the subviews. I add my UIRefreshControl with the following code:

// enable "pull to refresh"
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull To Refresh!" attributes:@{NSForegroundColorAttributeName : [UIColor whiteColor], NSFontAttributeName : [UIFont systemFontOfSize:17]}];
[refreshControl addTarget:self action:@selector(fetchArticles) forControlEvents:UIControlEventValueChanged];
refreshControl.backgroundColor = [UIColor colorWithRed:0.0f/255.0f green:102.0f/255.0f blue:153.0f/255.0f alpha:1.0];
refreshControl.tintColor = [UIColor whiteColor];
self.refreshControl = refreshControl;
[self.tableView addSubview:self.refreshControl];

I have another screen in my app that uses a UITableViewController, and its UIRefreshControl is way more different than the one I added for my UITableView.

The UIRefreshControl for a separate UITableView is slower when dragging and I usually have to drag FARTHER just to get it to start refreshing.

The UIRefreshControl for my UITableViewController on my other screen is faster when dragging and I don't have to drag so far to get it to start refreshing.

I prefer the smoother behavior of the UITableViewController's UIRefreshControl, so how do I get my UIRefreshControlfor my UITableView to behave more like the default one that belongs to UITableViewController?

Is this possible? Or is using a UIContainerView and using UITableViewController my only option?

Rafi
  • 1,902
  • 3
  • 24
  • 46

1 Answers1

1

UIRefreshControl is designed to work with a UITableViewController; on Apple's website it says:

Because the refresh control is specifically designed for use in a table view that's managed by a table view controller, using it in a different context can result in undefined behavior.

That being said, people have been successful without a UITableViewController: UIRefreshControl without UITableViewController. Use at your own risk.

Community
  • 1
  • 1
koen
  • 5,383
  • 7
  • 50
  • 89
  • Thanks for the link! I was a little hesitant to use the hacky `UITableViewController` instance solution but it worked perfectly! – Rafi May 18 '16 at 02:52