1

I've been searching for a really long time but I found no answer for my question(s).

In my app I have a segmented control with two buttons. When I toggle between those buttons I do:

  1. Show a loading screen as a subview
  2. do an url request to get the content to show in my tableview
  3. fill my dataArray for my TableView with the new data
  4. call reload data
  5. remove loading screen subview.

In most cases everything works fine, BUT..

Sometimes, really not often, the table view "crashes", after this 5 steps. It means. The view only show one or two cells. And when I scroll to top or bottom I only scroll into white. In my current solution I can't reproduce this error on my iPhone(IOS6), only in simulator(IOS7). I think it has something to do with scrolling while changing the data of the table view. It only occurs while scrolling and pressing the segmented control button shortly after started scrolling, but only sometimes. But it could have another reason for sure..

My Question is, what could cause the table view to layout wrong (only displaying some cells correctly and scrolling into white), any Idea? And how can I recover/redraw the whole tableview after this happened? Please help..

I read a lot about [tableview beginUpdates],[tableview endUpdates] and insertRows, but I think this is not the right solution in this case. Or tell me if I'm wrong.

Here is the main code snipped for steps 2-4. If another part of code could help, maybe the cellForRowIndexPath, let me know.

NSMutableArray *newResults = [[NSMutableArray alloc] initWithArray:[self getResultsForRequest:url]];

[resultsLock lock]; 
results = newResults; //results is the data source for my tableView
[resultsLock unlock];

[self.tableView reloadData];

Thanks to all responders.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
mr. jenkins
  • 21
  • 1
  • 5
  • It would be very helpful if you also added the crash log, stack trace or anything else that could point us in the right direction. – Stavash Jan 22 '14 at 15:40
  • I'm sorry, there is no crash log.. There is no console error or something like this.. :/ The app isn't even crashing. Its only like I described. After reloading the content, the table show some cells and you can scroll top and down, but there is only white.. Its so confusing, I can't figure it out.. – mr. jenkins Jan 22 '14 at 20:44

0 Answers0