首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >tableView reloadData + Parse

tableView reloadData + Parse
EN

Stack Overflow用户
提问于 2015-07-27 21:34:08
回答 1查看 287关注 0票数 0

我正试图在navigationBar中实现一个刷新按钮,所以当单击该按钮时,我需要重新加载tableView,我有这段代码,但它不能工作,因为我把println放在里面,所以函数被调用,我也在ViewDidAppear上声明了重新加载,但是什么都没有发生:

代码语言:javascript
复制
import UIKit

class CommentsTableViewController: PFQueryTableViewController {
@IBOutlet var tabletView: UITableView!


var object : PFObject?

// Initialise the PFQueryTable tableview
override init(style: UITableViewStyle, className: String!) {
    super.init(style: style, className: className)
}

required init(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)

}

// Define the query that will provide the data for the table view
override func queryForTable() -> PFQuery {
    var query = PFQuery(className: "gameScore")
    query.orderByDescending("createdAt")
    query.whereKey("ObjectId", equalTo: "XDP1rc8Rmq")

    return query
}

override func viewDidLoad() {
    super.viewDidLoad()


}

override func viewDidAppear(animated: Bool) {

    // Refresh the table to ensure any data changes are displayed
    self.tabletView.reloadData()
    println("Reloading")
}


override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


//override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell? {
    var cell = tableView.dequeueReusableCellWithIdentifier("CommentCellIdentifier") as! CommentsCell!
    if cell == nil {
        cell = CommentsCell(style: UITableViewCellStyle.Default, reuseIdentifier: "CommentCellIdentifier")
    }


    if let object = object?["user"] as? String {
        cell?.username?.text = object
    }


    return cell

}

func buttonIconAction(sender:UIButton!)
    {
    println("Reloading")
    self.tableView.reloadData()
    }

}

有什么建议吗?谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-27 21:50:41

与调用tableView.reloadData()不同,PFQueryTableViewController似乎有一个名为loadObjects()的方法。试着叫它。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31663704

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档