简体   繁体   中英

cellForRowAtIndexPath never gets called, but numberOfRowsInSection is

I have a viewController with a tableView outlet, and the controller is the dataSource of the tableView .

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 ).

BTW, cellForRowAtIndexPath did get called once when the controller is first loaded.

Can anyone please point me the right direction to look at? been stucked for a while already...

I'm using swift 2.0

Thanks!

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM