0

When I scroll my table view fast (with a long and quick gesture) so it will scroll for a few seconds more on screen displaying my cells (let's say 3-4 seconds) - and so very quickly I hit the back button to go back to the previous screen: it works... BUT then the scrolling would have come to a stop (on the screen that I cannot see anymore - so 3-4 seconds later): the app crashes! and that each time I do that "fancy" crash test.

I used my own table view cells - and I am a bit out of ideas of where to start to fond that bug. I can only think that the previous view tries to "release" something that obviously is not displayed anymore.

Has any of you experienced this? or have you tried on your own apps that "test" to ensure it will not crash like mine?

any pointer of help is of course highly appreciated!

Thanks

Cheers, geebee

EDIT1: thanks to your answers - I finally saw that this behavior happens if you put my removeallobjects like I was doing in the viewwilldisappear instead of viewDidDisappear method... all good now

geebee
  • 131
  • 1
  • 11
  • not sure what you are saying Nitish - or where you see that - and what I have not done to show it - what I am 200% certain is that without stackoverflow my app would have never been live!!! so BIG THANK YOU! – geebee Sep 23 '11 at 20:57

3 Answers3

0

In back button action check for this condition.

E.g

-(void)backButtonAction:(id)sender {

//If table is scrolling
 if([mTableView isDecelerating]){
    //Don't push back or condition you want to perform
}

else {
//your condition.
}

}

As we know tableview is hierarchy of UIScrollview we can use isDecelerating to check whether the table is scrolling when button is pressed.

Anand
  • 2,086
  • 2
  • 26
  • 44
  • I see what you are saying - so the back button would have no effect until the tableview has come to a stop - I'll give a try... THX a LOT Anand – geebee Sep 23 '11 at 21:03
0

When the view stops, it calls some functions of its scrollView delegate, which is your ViewController I guess.

When the user hits back, the navigationController release the ViewController it was showing. So if YOU didn't retain it somewhere, the ViewController will be deallocated and the view will send a message to an object that doesn't exists anymore.

In order to see if I'm right really quick, you can add the NSZombieEnable = YES in your project. After that you will get more precise informations about your crash.

My guess is that you will see something like : "XXXX message send to a deallocated instance [UIViewController XXXX]"

CedricSoubrie
  • 6,657
  • 2
  • 39
  • 44
  • that does sound like making lots of sense what you are saying. I don't know how to act on your zombie comment, what do I need to put where? Or do I need to try to retain the view a bit longer...? – geebee Sep 23 '11 at 21:00
  • It's a settings in your XCode project. I'd really advice you to set it. Look for "NSZombieEnabled" on Google on how to do it or look the brief description here : http://stackoverflow.com/questions/5810931/how-to-turn-off-nszombieenabled-in-xcode-4 – CedricSoubrie Sep 23 '11 at 23:05
0

The cause of this would appear to be that your UITableView is living longer than its datasource or delegate - are you sure its not leaking?

In the dealloc method for your datasource / delegate you should set

tableView.delegate = nil;
tableView.dataSource = nil;
Daniel Broad
  • 2,512
  • 18
  • 14
  • thanks to your answer - I finally saw that this behavior happens if you put my removeallobjects like I was doing in the viewwilldisappear instead of viewDidDisappear method... all good now – geebee Oct 06 '11 at 14:17