Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为什么重复的单元格显示在UITableView中?_Ios_Swift_Uitableview - Fatal编程技术网

Ios 为什么重复的单元格显示在UITableView中?

Ios 为什么重复的单元格显示在UITableView中?,ios,swift,uitableview,Ios,Swift,Uitableview,现在为什么重复的单元格会出现在UITableView中 正如你们在这张GIF中看到的,我按下一个单元格按钮来做一些淡入淡出的效果,但其他单元格也会受到影响 细胞的数量总是10 numberOfCells = 10 我总是制作桌面视图,我对设置很有把握,这是苹果方面的错误吗 编辑: 单元格的创建方式: func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITabl

现在为什么重复的单元格会出现在
UITableView

正如你们在这张GIF中看到的,我按下一个单元格按钮来做一些淡入淡出的效果,但其他单元格也会受到影响

细胞的数量总是10

numberOfCells = 10
我总是制作桌面视图,我对设置很有把握,这是苹果方面的错误吗

编辑:

单元格的创建方式:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
    let cell = tableView.dequeueReusableCellWithIdentifier("brandCell", forIndexPath:indexPath) as! CustomCell1INF
    cell.selectionStyle = UITableViewCellSelectionStyle.None
    cell.frame = self.view.frame
    return cell
}

发生这种情况是因为重复使用了
UITableViewCell

当您按下按钮时更改了单元格,您需要在数据源模型中跟踪该单元格


cellforrowatinexpath
中,您必须添加一个条件来检查该按钮是否按下,然后相应地显示相应的视图。

您能在创建单元格的位置显示代码吗?这肯定不是applei的bug只是编辑了这篇文章,还是说自定义单元格脚本?那太长了……我认为这不是重复使用电池的正确方式。在恢复单元格时,您不需要检查nill吗?请考虑方法名称
dequeueReusableCellWithIdentifier
。单元格被重复使用(一直创建一个新的单元格会导致快速滚动时出现较大的延迟)。一旦您将单元格出列,您需要配置您以前可能更改过的任何视图。一般来说,最好在单元格的代码中处理这些视图,例如在
prepareforeuse
中。是的,您有一个有效点,即使是willDisplayCell也应该工作
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
    let cell = tableView.dequeueReusableCellWithIdentifier("brandCell", forIndexPath:indexPath) as! CustomCell1INF
    cell.selectionStyle = UITableViewCellSelectionStyle.None
    cell.frame = self.view.frame
    return cell
}