Uitableview 带Swift 3的ViewController中的GroupTable
我将表格放在我的ViewController中。我做了一张桌子。因此,我选择表并在属性检查器的样式中选择“Grouped”Uitableview 带Swift 3的ViewController中的GroupTable,uitableview,swift3,uitableviewsectionheader,Uitableview,Swift3,Uitableviewsectionheader,我将表格放在我的ViewController中。我做了一张桌子。因此,我选择表并在属性检查器的样式中选择“Grouped” var TableArray = [["Home","Apple","Orange","Pineapple"],["Flour","Cake Flour"]] func numberOfSectionsInTableView(tableView: UITableView) -> Int { return TableArray.count } fu
var TableArray = [["Home","Apple","Orange","Pineapple"],["Flour","Cake Flour"]]
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return TableArray.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
debugPrint(TableArray[section].count)
return TableArray[section].count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: TableArray[indexPath.section][indexPath.row], for: indexPath) as UITableViewCell
cell.imageView?.image = menuIconImage[indexPath.row]
cell.textLabel?.text = TableArray[indexPath.section][indexPath.row]
cell.selectionStyle = UITableViewCellSelectionStyle.blue
tableView.rowHeight = 56.0;
return cell
}
当我运行应用程序时,表中只显示“Home”、“Apple”、“Orange”、“菠萝”它不显示“面粉”、“蛋糕粉”
我不知道问题出在哪里。请帮帮我 方法
numberOfSectionsInTableView
错误,默认值为1
Swift 3语法为:
func numberOfSections(in tableView: UITableView) -> Int {
return TableArray.count
}
根据命名约定,变量名称应以小写字母开头。Yes bro@vadian。但是,我想要两部分。其中一部分包括-->“家”、“苹果”、“橘子”、“菠萝”。第二部分包括-->“面粉”、“蛋糕粉”。我该怎么做?Bro您使用了错误的API。用我答案中的方法替换你的方法。兄弟@vadian,你的代码对我有用。。。非常感谢兄弟!!!!:):)