我已经创建了一个tableview控制器,但是没有调用它的委托方法。我提到了一些网站,但在我的代码中没有遇到任何错误。请帮我。
class FriutsTableViewController: UITableViewController {
var fruitsList : [AnyObject] = ["We", "love", "swift"];
override func viewDidLoad() {
super.viewDidLoad()
let myCatalog = Catalog()
fruitsList = myCatalog.fruits;
//let view = ViewController()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
override func numberOfSectionsInTableView(tableView: UITableView!) -> Int {
return 0
}
override func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
return fruitsList.count
}
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
var cell = tableView.dequeueReusableCellWithIdentifier("fruitIdentifier") as? UITableViewCell
if !cell {
cell = UITableViewCell(style: UITableViewCellStyle.Value1, reuseIdentifier: "fruitIdentifier")
}
cell!.textLabel.text = fruitsList[indexPath.row] as AnyObject! as String!
return cell
}
@objc func fetchFruits() {
}
提前致谢。
尝试
return 1
在
numberOfSectionsInTableView.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句