Reputation: 1
Without prefersLargeTitles, I should have to pull down a bit before the UIRefreshControl begins the refresh, but when I turn on large titles, it starts instantly.
I have removed the Storyboard and I am trying to create everything programatically. What am I missing?
import Foundation
import UIKit
class TweakManagerViewController: UIViewController {
var tableView = UITableView()
var refreshControl = UIRefreshControl()
override func viewDidLoad() {
super.viewDidLoad()
setupTableView()
self.navigationController?.navigationBar.prefersLargeTitles = true
self.title = "Title"
}
func setupTableView() {
tableView.refreshControl = refreshControl
view.addSubview(tableView)
tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
tableView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
tableView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
}
}
Upvotes: 0
Views: 50
Reputation: 1
I was finally able to solve it. I was supposed to use a UITableViewController, not a UIViewController. After switching to a UITableViewController, everything works as expected.
Upvotes: 0
Reputation: 51
You have added everything correctly make sure that you have also added the target action to make the UIRefreshControl work as expected
// Add target-action for refresh control in your view did load
refreshControl.addTarget(self, action: #selector(refreshData), for: .valueChanged)
@objc func refreshData() {
// Perform the actions you want when the user triggers the refresh control
refreshControl.endRefreshing()
}
Upvotes: 0