开发者

fast table view scroll and back button hit

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


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;


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.


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]"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜