UITableView show only first row

六月ゝ 毕业季﹏ 提交于 2019-12-12 06:03:57

问题


My app has 3 tabs (Kids, Points and Requests) with same result list. I'm using a custom cell to show kids information with same data in 3 tabs.

For example:

Kids Tab:

  • Kid name 1
  • Kid name 2
  • Kid name 3

Points tab:

  • Kid name 1
  • Kid name 2
  • Kid name 3

Requests tab:

  • Kid name 1
  • Kid name 2
  • Kid name 3

When I go to Requests and select a kid I push another view with total requests per selected kid. Now the VERY weird thing, when I back to Points or Kids tab and reload (i'm using pull to refresh, what is not the problem) only the FIRST row appear!

I'm using NSXML to parse the XML and adding to a NSMutableArray called itemList after this I populate the tableview.

What I already tried:

  1. tried to replace NSXML with TBXML parser without success the sameproblem occurs.

  2. tried to remove custom cells and use the default cell without success.

  3. tried to change the cell identifiers without success.

  4. tried to change all variables names trying to avoid variable replacement.

  5. NSLog in all vars and objs in app trying to show everything without success.

  6. tried to remove pull to refresh and same problem occurs.

All kind of help its appreciated :)

Thanks! Cleber Santos


回答1:


The first thing you need to know is if this is a data problem or if this is a tableviewdelegate problem. I would start by swapping a static NSArray in place of your data source then re-running your app in the simulator. If it works as expected, then that means that the static data "worked" and the problem is your data source.

If the static NSArray data doesn't work, then that means your problem is with your tableView's delegate or (more likely) dataSource methods. If it turns out this is the case, then try to hunt it down and supply a code sample in a future post if you need help.

NOTE: Before you swap out your data source for the NSArray would be a good time to branch your source in Git/Subversion/whatever so that if it doesn't work with the static data you can pull back your changes. And DON'T TELL ME YOU'RE NOT USING SCM!!!!!




回答2:


you need to make sure your data source is correct. The UITableView is just that, a view. You need to check that you actually have the data stored properly regardless of your view. My guess is that you clobbered your data when switching views.



来源:https://stackoverflow.com/questions/4546978/uitableview-show-only-first-row

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!