开发者

CABasicAnimation with delegate crash

self.mLineAnimation = [CABasicAnimation animationWithKeyPath:@"path"];
mLineAnimation.fromValue = (id)mStartPath;
mLineAnimation.toValue = (id)mEndPath;
mLineAnimation.duration = 2; 
mLineAnimation.repeatCount = 0;
[mLineAnimation setDelegate:self];
mLineAnimation.removedOnCompletion = NO;
mLineAnimation.fillMode = kCAFillModeForwards;
mLineAnimation.timingFunction = [CAMediaTimingFunction
                                    functionWithName:kCAMediaTimingFunct开发者_如何学运维ionEaseInEaseOut];
[mShapeLayer addAnimation: mLineAnimation forKey: @"animateLine"];

Notice that I set the delegate in order to implement animationDidStop. My animations runs in a table view cell. Now when I am scrolling fast through the table, the application crashes with EXC_BAD_ACCESS. If I do not set the delegate, the application doesn't crash. Could you please lead what to do here? The stack trace is next:

#0  0x0168ea63 in objc_msgSend
#1  0x056ff0a0 in ??
#2  0x00ee36cb in run_animation_callbacks
#3  0x00ee3589 in CA::timer_callback
#4  0x0150dfe3 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
#5  0x0150f594 in __CFRunLoopDoTimer
#6  0x0146bcc9 in __CFRunLoopRun
#7  0x0146b240 in CFRunLoopRunSpecific
#8  0x0146b161 in CFRunLoopRunInMode
#9  0x01cd9268 in GSEventRunModal
#10 0x01cd932d in GSEventRun
#11 0x003da42e in UIApplicationMain
#12 0x00002580 in main at main.m:14


The animation stops after the object that created the animation has been destructed (the object that "self" refers to in "self.mLineAnimation"). The animation then tries to message the destructed object.

Run your executable with NSZombieEnabled, that will turn the crash in objc_MsgSend into an Objective-C exception that will break the debugger.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜