Kev*_*OUX 4 uitableview ios swift
在我的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
}
Run Code Online (Sandbox Code Playgroud)
正确调用方法"numberOfRowsInSection",但从不调用"numberOfSectionsInTableView".
我错过了什么?
您可以在Obj-c中回复
方法的名称不正确.它应该是numberOfSectionsInTableView(_:).
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return self.mQuoteObjects.count
}
Run Code Online (Sandbox Code Playgroud)
小智 7
如果有人使用SWIFT 5
func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 2
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3648 次 |
| 最近记录: |