首先,在viewDidLoad中初始化相关数据:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
//添加刷新
refreshControl.addTarget(self, action: "refreshData", forControlEvents: UIControlEvents.ValueChanged)
refreshControl.attributedTitle = NSAttributedString(string: "松手刷新新闻")
newsTableView.addSubview(refreshControl)
}
这样下拉刷新已经可以看到了:
接下来把Selector 完善一下,添加refreshData方法:
// 刷新数据
func refreshData() {
let bquery = BmobQuery(