gpt4 book ai didi

ios - Swift tableView 委托(delegate)方法未被调用

转载 作者:搜寻专家 更新时间:2023-10-31 08:17:03 25 4
gpt4 key购买 nike

我已经创建了一个 TableView Controller ,但它的委托(delegate)方法没有被调用。我引用了几个网站,并没有在我的代码中发现任何错误。请帮助我。

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.

关于ios - Swift tableView 委托(delegate)方法未被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26230244/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com