[英]numberOfRowsInSection called multiple times but cellForRowAtIndexPath never called
[英]cellForRowAtIndexPath never gets called, but numberOfRowsInSection is
我有一个带tableView插座的viewController
,控制器是tableView
的dataSource
。
当我尝试使用tableView.reloadData()
重新加载tableView
,调用了dataSource方法numberOfRowsInSection
,并且在控制台中,我可以看到在第0节和第1节中numberOfRows
为1。但是,未调用cellForRowAtIndexPath
。 (我在cellForRowAtIndexPath
设置了一个断点)。
顺便说一句,当第一次加载控制器时, cellForRowAtIndexPath
确实被调用了一次。
谁能给我指出正确的方向吗? 已经被卡住了一段时间了...
我正在使用Swift 2.0
谢谢!
您能否确保在主线程上正在调用tableView.reloadData()
。 如果已经在执行此操作,请检查调用reloadData
的UITableView
实例是否与视图中显示的UITableView
相同。 这是导致numberOfRowsInSection
被调用而不是cellForRowAtIndexPath
的常见原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.