0
由於某種原因數組沒有被放入表視圖任何原因爲什麼? CellWithIdentifier
已正確實例化,故事板中的單元格具有相同的標識符。還確認該陣列已填充。我也已經連接故事板上的數據源和委託。爲什麼tableview不顯示數組?爲什麼數組不在tableview中?
let TextQuery = PFQuery(className: "submit")
TextQuery.findObjectsInBackgroundWithBlock({
(objects: [AnyObject]?, error: NSError?) -> Void in
var object = objects as! [PFObject]
for i in 0...object.count-1{
self.arrayOftexts.append(object[i].valueForKey("text") as! String)
print(self.arrayOftexts)
}
})
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return arrayOftexts.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = myTableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
cell.textLabel?.text = arrayOftexts[indexPath.row]
print("added to tableview")
return cell
}
你根本調用'tableview.reloadData()'嗎? (應該是你的for循環之後大概) – Fonix
你輸入了下面的方法嗎? func numberOfSectionsInTableView(tableView:UITableView) - > Int { return 1 } – Diego