【发布时间】:2015-11-20 06:15:27
【问题描述】:
点击UIButton 时,我无法向UITableView 添加行。
我有两个自定义单元格 xib - 一个包含 UILabel,另一个包含 UIButton。
表格单元格的数据从两个字典(answersmain 和 linesmain)加载。
这是UITableView主要功能的代码:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.linesmain["Audi"]!.count + 1
}
// 3
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if(indexPath.row < 3){
var cell:TblCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as! TblCell
cell.lblCarName.text = linesmain["Audi"]![indexPath.row]
return cell
} else {
var celle:vwAnswers = self.tableView.dequeueReusableCellWithIdentifier("cell2") as! vwAnswers
celle.Answer.setTitle(answersmain["Good car"]![0], forState:UIControlState.Normal)
return celle
}}
我在这里放什么?
@IBAction func option1(sender: UIButton) {
// I need to add rows to the uitableview from two dictionaries into two different xibs
}
【问题讨论】:
标签: ios swift uitableview dictionary custom-cell