我想在一行与自定义单元格指数路径添加一个副行不使用图书馆。我怎样才能添加子行时didselectRowAt(SWIFT 3)
当我选择的细胞,另一小区出现该单元下面,重复用于每个小区 诗此操作:
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return arrayEnum.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var CellTB: UITableViewCell!
let cell = tableView.dequeueReusableCell(withIdentifier: "enumCell", for: indexPath)as! UserFlagTableViewCell
cell.UserflagLabel.text = arrayEnum[indexPath.row].rawValue
CellTB = cell
// let cell1 = tableView.dequeueReusableCell(withIdentifier: "freeTextCell", for: indexPath)as! FreeTextTableViewCell
// cell1.sendButton.addTarget(self, action: Selector("sendUserflagEvent:"), for: .touchUpInside)
// CellTB = cell1
return CellTB
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.tableView.insertRows(at: [IndexPath(row: UserFlagType.userFlagTypes.count-1, section: 0)], with: .automatic)
self.tableView.beginUpdates()
self.tableView.endUpdates()
}
:其中它会出现这是相同的
我尝试这种细胞
我有1节 我有6行
不,这不是为我工作,我怎么能显示新的细胞? 原因:“试图插入一行6成部分0,但更新后只有6个在第0行” 的libC++ abi.dylib:与类型的未捕获的异常NSException –
IndexPath从0开始,而你是终止做array.count,从1开始。所以...你必须做array.count - 1.我将编辑答案,Sry – Mellao
我有一个枚举的列表(6枚)我把它放在表视图和我想要当我选择一个单元格出现一个新的自定义单元格(我有一个按钮和文本发送)。我不知道它是如何做到的。和我不能添加到可能枚举数组 –