Reputation: 719
I'm seeing a crash in UIScrollView because the delegate was released from memory before the scrollView has finished an animation.
I know this to be the cause, and the solution should be to manually nil out the delegate of the UIScrollView when the delegate hits its own dealloc call. I've done this to every viewController that I can find which has a UIScrollView subview, but the crash still persists. I know the root cause is that UIScrollView's delegate is assign instead of weak, and I'm curious if I can override this somehow (through a category?).
Is there another solution?
Here's the dump of the crash, I find it curious that one of the calls on the stack references UITextView (which inherits from UIScrollView), could this offer up a clue to the location of the offending UIScrollView?
Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0xc1a9e521
0 libobjc.A.dylib objc_msgSend + 5 respondsToSelector:
1 UIKit -[UIScrollView(UIScrollViewInternal) _delegateScrollViewAnimationEnded] + 52
2 UIKit -[UIScrollView(UIScrollViewInternal) _scrollViewAnimationEnded:finished:] + 184
3 UIKit -[UITextView _scrollViewAnimationEnded:finished:] + 306
4 UIKit -[UIAnimator stopAnimation:] + 476
5 UIKit -[UIAnimator(Static) _advanceAnimationsOfType:withTimestamp:] + 304
6 UIKit -[UIAnimator(Static) _LCDHeartbeatCallback:] + 52
7 QuartzCore CA::Display::DisplayLinkItem::dispatch() + 98
8 QuartzCore CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 366
9 IOMobileFramebuffer IOMobileFramebufferVsyncNotifyFunc + 90
10 IOKit IODispatchCalloutFromCFMessage + 256
11 CoreFoundation __CFMachPortPerform + 132
18 UIKit UIApplicationMain + 1440
Upvotes: 2
Views: 1128
Reputation: 406
this may be the same as the following issue.
basically set UIScrollView
's delegate
to nil
in dealloc
Upvotes: 0