Rafi
Rafi

Reputation: 1922

iOS - UITableView's UIRefreshControl vs. UITableViewController's UIRefreshControl

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?

Upvotes: 0

Views: 274

Answers (1)

koen
koen

Reputation: 5729

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.

Upvotes: 1

Related Questions