Dav*_*son 5 uibutton uitableview custom-cell ios swift
我有一个问题,我不知道如何解决。
我有两个自定义单元格笔尖 - 两者的数据都是从单独的数组中获取的。
结构如下
nib1-cell line1
nib1-cell line2
...
nib1-cell line n
nib2-cell line1
末尾始终有一个 nib2-cell,后缀为uibutton. 
一旦uibutton按下 - nib1 数组就会被附加。
我找到了一种如何在 底部插入值的方法tableview,但是当我向下或向上滚动时,带有 nib2 的单元格将被重用并替换为 nib1 单元格数据。

我怎样才能防止这些单元被重复使用或保存它们的状态?
谢谢。
更新:数据源和 cellForRowAtIndexPath 代码
func tableView(tableView: UITableView, numberOfRowsInSection 部分: Int) -> Int {
    return someTagsArray.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell     {
    if(indexPath.row < someTagsArray.count - 1){
        var cell:TblCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as! TblCell
        cell.lblCarName.text = someTagsArray[indexPath.row]
        return cell
    } else if (indexPath.row == someTagsArray.count - 1){
      var celle:vwAnswers = self.tableView.dequeueReusableCellWithIdentifier("cell2") as! vwAnswers
        celle.Answer1.setTitle(answersdict[answersdict.endIndex - 2], forState:UIControlState.Normal)
        answertitle1 = "\(celle.Answer1.currentTitle!)"
        celle.Answer2.setTitle(answersdict.last, forState:UIControlState.Normal)
        answertitle2 = "\(celle.Answer2.currentTitle!)"
        //println(answertitle2)
        return celle
    } else {
                    var cell2:TblCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as! TblCell
        return cell2
    }
}
您必须确定要放入哪种类型的单元格cellForRowAtIndexPath并将正确的可重用单元格出队。也许类似if (indexPath.row + 1)%3 == 0然后将应答单元出队。
但是,您可能想考虑使用节标题来代替。如果不看看您如何实现数据源,很难说。
| 归档时间: | 
 | 
| 查看次数: | 2934 次 | 
| 最近记录: |