I have a viewController
with a tableView outlet, and the controller is the dataSource
of the tableView
.
我有一个带有tableView插座的viewController,而控制器是tableView的dataSource。
When I tried to reload the tableView
using tableView.reloadData()
, the dataSource method numberOfRowsInSection
is called, and in the console I could see that the numberOfRows
is 1 in both section 0 and section 1. However, the cellForRowAtIndexPath
is not called. (I put a breakpoint in cellForRowAtIndexPath
).
当我尝试使用tableView.reloadData()重新加载tableView时,调用dataSource方法numberOfRowsInSection,并且在控制台中我可以看到numberOfRows在0和section 1中都是1。但是,不调用cellForRowAtIndexPath。 (我在cellForRowAtIndexPath中放了一个断点)。
BTW, cellForRowAtIndexPath
did get called once when the controller is first loaded.
BTW,cellForRowAtIndexPath在首次加载控制器时调用了一次。
Can anyone please point me the right direction to look at? been stucked for a while already...
谁能指点我正确的方向看?已经被困了一段时间......
I'm using swift 2.0
我正在使用swift 2.0
Thanks!
谢谢!
1 个解决方案
#1
0
Could you please ensure that tableView.reloadData()
is being called on main thread. If you are already doing this then check that the UITableView
instance you called reloadData
on is the same UITableView
that you have displayed in your view. This is a common cause for numberOfRowsInSection
getting called but not cellForRowAtIndexPath
.
你能否确保在主线程上调用tableView.reloadData()。如果您已经这样做,那么请检查您调用reloadData on的UITableView实例是否与您在视图中显示的UITableView相同。这是调用numberOfRowsInSection而不是cellForRowAtIndexPath的常见原因。
#1
0
Could you please ensure that tableView.reloadData()
is being called on main thread. If you are already doing this then check that the UITableView
instance you called reloadData
on is the same UITableView
that you have displayed in your view. This is a common cause for numberOfRowsInSection
getting called but not cellForRowAtIndexPath
.
你能否确保在主线程上调用tableView.reloadData()。如果您已经这样做,那么请检查您调用reloadData on的UITableView实例是否与您在视图中显示的UITableView相同。这是调用numberOfRowsInSection而不是cellForRowAtIndexPath的常见原因。