当我运行代码时,我成功地将JSON数据馈送到我的应用程序中,以呈现此关联的UIView。我有一个tableView充分链接到这个文件,当我运行应用程序时,我看到了tableview本身。但是3个数据源函数中没有一个会自动调用 - 在打了2个小时后,'wtf'打印语句,will.not.print。为什么我的UITableViewDataSource函数不被调用?
我错过了什么?此代码是相同到我写的所有其他tableviewdatasource代码,这根本不会工作或呈现我提供的JSON数据
有没有人有想法或建议?谢谢!
import UIKit
class ChooseUserViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
var users: [BackendlessUser] = []
override func viewDidLoad() {
super.viewDidLoad()
loadUsers()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//MARK: UITableViewDataSource
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
print("wtf")
return users.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("chooseCell", forIndexPath: indexPath)
let user = users[indexPath.row]
print("wtf!")
cell.textLabel?.text = user.email
return cell
}
}
你是否已经将你的TableView内的StoryView作为Delegate&Datasource赋给ViewController? – derdida
您是否设置了数据源? – GoodSp33d
@derdida这是另一回事。 :P – ZeMoon