我有一个 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
EDIT:
这是我的部分的片段:
func numberOfSectionsInTableView(tableView:UITableView!)->Int
{
return 1
}
我的线程堆栈图片:https://i.stack.imgur.com/5USNn.png https://i.stack.imgur.com/5USNn.png
在 UITableView 中,有很多情况,由于 tableview 的自动刷新等原因,不同的委托方法会被多次调用。
检查此答案以获取更多信息。 https://stackoverflow.com/questions/2638359/uitableview-delegate-method-called-twice
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)