ios - Swift:无法使用类型为 'addSubview' 的参数列表调用 '(UIRefreshControl!)'

标签 ios swift uitableview

我正在尝试使用 Swift 2 在我的 UITableView 中创建一个刷新请求。我在我的类声明下面添加了这个:

var refreshControl: UIRefreshControl!

这在我的 viewDidLoad() 中

self.refreshControl = UIRefreshControl()
self.refreshControl.attributedTitle = NSAttributedString(string: "Pull to refresh")
self.refreshControl.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)
self.tableView.addSubview(refreshControl)

但是,最后一行给出了以下错误:

Cannot invoke 'addSubview' with an argument list of type '(UIRefreshControl!)'

我在这里做错了什么?我该如何解决这个问题?

我的代码截图:

Code screenshot

最佳答案

tableView 在哪里?我在你的代码中只看到 appsTableView

关于ios - Swift:无法使用类型为 'addSubview' 的参数列表调用 '(UIRefreshControl!)',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31090778/

相关文章:

ios - 使用另一个按钮执行与后退按钮相同的操作

ios - Xcode8:图像字面量在框架中的使用

ios - 有什么方法可以在 Storyboard 中添加缩写/速记/常量来代替字符串?

ios - Swift Eureka 表单库 - 如何在表单呈现后自定义字段

ios - 延迟显示异步获取的项目

ios - 问题 : Reloading a tableView Section hides other tableView sections

ios - swift 3 如何获取明天和昨天的日期(注意特殊情况)新月或新年

swift - 最初仅针对 iPad 设置后,无法让图标资源注册显示在 iPhone 上

ios - 如何修复此无效更新 : invalid number of rows in section 0 error?

iphone - UITableViewCell一遍又一遍地重复