简体   繁体   English

UIRefreshControl和tableFooterView = UIView()

[英]UIRefreshControl and tableFooterView = UIView()

In my tableView I need to have self.tableView.tableFooterView = UIView() otherwise the table scrolls too far down. 在我的tableView中,我需要有self.tableView.tableFooterView = UIView(),否则该表向下滚动太远。 The problem is if I add this then my pull to refresh UIRefreshControl no longer works. 问题是,如果我添加此代码,则刷新UIRefreshControl的请求将不再起作用。 Is there a way to have both? 有办法两者兼得吗?

There's no reason why you can't have both. 没有理由不能同时拥有两者。 Have you added the UIRefreshControl in the right way? 您是否以正确的方式添加了UIRefreshControl Here's working code from a project of mine: 这是我的一个项目的工作代码:

var pullToRefreshControl : UIRefreshControl!

override func viewDidLoad() {
        super.viewDidLoad()

        self.setFooterView()
        self.addPullToRefreshView()
    }

private func setFooterView() {

        let footerView = UIView()

        let footerLabel = UILabel()
        footerLabel.text = "Table Footer"
        footerLabel.sizeToFit()
        footerView.addSubview(footerLabel)

        self.tableView.tableFooterView = footerView
    }

private func addPullToRefreshView() {

        pullToRefreshControl = UIRefreshControl()
        pullToRefreshControl.attributedTitle = NSAttributedString(string: "Pull To Refresh")
        pullToRefreshControl.addTarget(self, action: "refresh:", forControlEvents: .ValueChanged)

        self.tableView.addSubview(pullToRefreshControl!)
    }

为此创建一个自定义控件刷新控件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM