13

My app is crashing when my UITableView is released whilst animating. The app functions without issue so long as the animation completes. Below is the result of a tap on the UIButton which calls [tableView setContentOffset:offset animated:YES]; and then a lightning quick tap on the backBarButtonItem which pops the UITableViewController:

#0  0x31ec3ebc in objc_msgSend
#1  0x33690248 in -[UIScrollView(UIScrollViewInternal) _scrollViewAnimationEnded]
#2  0x30defa14 in -[NSObject performSelector:withObject:]
#3  0x33690098 in -[UIAnimator stopAnimation:]
#4  0x3368fb7c in -[UIAnimator(Static) _advance:]
...

I've never seen a crash on _scrollViewAnimationEnded and apparently neither has Google. I have tried calling [tableView setContentOffset:offset animated:NO]; from the UITableViewController's - (void)viewWillDisappear:(BOOL)animated method, but this did not solve the issue.

Any ideas for stopping a UITableView or UIScrollView in the midst of animating?

3 Answers3

28

This looks like it might be a delegate issue. Do you have a delegate for the table, and, if so, is it dealloc'd when the table is? Try nil'ing out your tableView's delegate before releasing it.

[The tableView is retained by CoreAnimation while it's animating, so that's probably not the problem.]

Ben Gottlieb
  • 85,404
  • 22
  • 176
  • 172
  • 1
    I'm not explicitly releasing the table view -- the issue occurred when its controller was popped from view (and if dictated necessary by the navigation controller removed from memory). Still, I think you solved it...ever since assigning and nil'ing the table view's delegate when the view will appear/disappear I have not been able to reproduce this crash. Thanks! – Metric Scantlings Dec 15 '09 at 00:26
  • 3
    By the way, I saw this crash even when using ARC. Be sure to nil out the table delegates manually! – MikecheckDev Jul 11 '13 at 18:53
1

I think the problem with you is that you are releasing the datasource array, before you release the tableView. try checking this out too in the dealloc

Madhup Singh Yadav
  • 8,110
  • 7
  • 51
  • 84
0

This may happen if you inserted a refresh controller into a table view as a subview (my hint, never do that)...

Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179