4

我有一个 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

4

1 回答 1

2

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

检查此答案以获取更多信息。

于 2015-01-26T08:16:37.177 回答