在我的 ViewController 中,我有一个 UITableView 和这些方法:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if(self.mQuoteObjects.count > 0){
return 1
}
return 0
}
func tableView(tableView: UITableView, numberOfSectionsInTableView section: Int) -> Int {
let nbItem = self.mQuoteObjects.count
return nbItem
}
方法“numberOfRowsInSection”被正确调用,但“numberOfSectionsInTableView”从未被调用。
我错过了什么?
你可以在 Obj-c 中响应
最佳答案
方法名称不正确。它应该是 numberOfSectionsInTableView(_:)
。
参见 UITableViewDataSource protocol reference .
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return self.mQuoteObjects.count
}
关于ios - numberOfSectionsInTableView 未调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29803132/