gpt4 book ai didi

ios - 为什么我的 tableView 函数运行了 3 次?

转载 作者:搜寻专家 更新时间:2023-10-31 19:35:21 25 4
gpt4 key购买 nike

我有一个 UITableView 并且我有执行它所需的方法之一:

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
println("section is \(section)")
println(self.items.count) // self.items.count = 3
return self.items.count
}

在我的日志中,我看到该方法运行了 3 次:

section is 0
3
section is 0
3
section is 0
3

编辑:

这是我的部分的片段:

func numberOfSectionsInTableView(tableView:UITableView!)->Int
{
return 1
}

我的线程堆栈图片:http://i.imgur.com/90dakCu.png

最佳答案

在 UITableView 中,有很多情况,不同的委托(delegate)方法会由于诸如自动刷新 tableview 之类的原因而被多次调用。

Check this answer for more informations.

关于ios - 为什么我的 tableView 函数运行了 3 次?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28144806/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com