Refresh Control - showing above TV

2019-08-19 20:31发布

问题:

I'd like to ask you how can I show UIActivityControl under TV cells. This is how it's showed right now. Thanks

(self.tableView.refreshControl = self.refresh_control doesn't work)

Code:

override func viewDidLoad() {
    super.viewDidLoad()

    self.refresh_control = UIRefreshControl()
    self.refresh_control.attributedTitle = NSAttributedString(string: "Aktualizace")
    self.refresh_control.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)
    self.view.addSubview(self.refresh_control)
    self.view.bringSubviewToFront(self.tableView)
}

回答1:

You don't need the refresh_control member, nor do you need to add refresh_control as a subView.

UITableViewController has a refreshControl member.

Try this:

self.refreshControl = UIRefreshControl()
self.refreshControl.attributedTitle = NSAttributedString(string: "Aktualizace")
self.refreshControl.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)