我的应用程序创建 UIView 的自定义子类的实例,并将这些实例水平放置在彼此相邻的位置。创建 UIView 类的新实例后,我可以将其添加到 UIScrollView 并重置 contentsize。然后我打电话
[UIScrollView setContentOffset:(some point) animated:NO]
。这工作得很好。问题是当我用动画调用上述方法时,即
[UIScrollView setContentOffset:(some point) animated:YES]
应用程序崩溃。调用堆栈如下所示:
> #0 0x3145b870 in ___forwarding___ ()
> #1 0x313b6650 in _CF_forwarding_prep_0 ()
> #2 0x317d84a2 in -[UIAnimator stopAnimation:] ()
> #3 0x317d84a2 in -[UIAnimator stopAnimation:] ()
> #4 0x317d7f0e in -[UIAnimator(Static) _advance:withTimestamp:] ()
> #5 0x317d7e00 in -[UIAnimator(Static) _LCDHeartbeatCallback:] ()
> #6 0x3531d86e in CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long) ()
> #7 0x3531d7c4 in CA::Display::IOMFBDisplayLink::callback(__IOMobileFramebuffer*,
> unsigned long long, unsigned long long, unsigned long long, void*) ()
> #8 0x33a56000 in IOMobileFramebufferVsyncNotifyFunc ()
> #9 0x36e3c60c in IODispatchCalloutFromCFMessage ()
> #10 0x31422f12 in __CFMachPortPerform ()
> #11 0x3142d522 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
> #12 0x3142d4c4 in __CFRunLoopDoSource1 ()
> #13 0x3142c312 in __CFRunLoopRun ()
> #14 0x313af4a4 in CFRunLoopRunSpecific ()
> #15 0x313af36c in CFRunLoopRunInMode ()
> #16 0x32888438 in GSEventRunModal ()
> #17 0x316b4cd4 in UIApplicationMain ()
当我启用 Zombies 时,应用程序输出会产生:
*** -[__NSArrayM removeObject:]: message sent to deallocated instance 0x113dbb10
附加信息:UIScrollView 的委托从未设置。我正在使用 ARC。