ipad - CATiledLayer drawLayer :inContext: crashing when the view is deallocated while the image to draw is being retrieved

标签 ipad core-graphics catiledlayer

当我的 CATiledLayer 正在检索图像以在后台线程中绘制时,当我的 ViewController 被释放时,我的应用程序崩溃了。我收到一条消息

-[MyViewController respondsToSelector:]: message sent to deallocated instance 0x8f58e00

并且调试器显示
0 ___forwarding___
1 __forwarding_prep_0__
2 -[CATiledLayer(CATiledLayerPrivate) canDrawRect:levelOfDetail:]
3 tiled_layer_render
4 CAImageProviderThread
5 CAImageProviderBackgroundThread
6 CA::DispatchGroup::thread
7 thread_fun
8 _pthread_start

现在,我确实想释放 MyViewController 的某个实例,因为我不再需要它了。但是当它从后台线程返回时,如何阻止它崩溃呢?

最佳答案

解决了。在解除分配 MyViewController 时,我应该将 CATiledLayer 的委托(delegate)设置为 nil。从现在开始,我会记得为代表们这样做。

关于ipad - CATiledLayer drawLayer :inContext: crashing when the view is deallocated while the image to draw is being retrieved,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3656011/

相关文章:

iOS:一个完整​​的 360 度旋转使用 block ,而不是 CABasicAnimation

objective-c - 使用 CATiledLayer 绘制 Core Data 实体信息时如何正确处理线程

ipad - 在辅助线程上安排 NSStreams

ios - png 中的阴影路径与阴影

ios - 在 iPhone/iPod/iPad 上调用电话

ios - 需要像 iOS 中的控件一样制作甘特图,进行绘制或 subview ?

iphone - 如何平铺 UIWebView?

ios - GMSGroundOverlay 动画 - 我应该使用 CATiledLayer 吗?

iphone - Apple 是否允许监控跳板事件?

objective-c - App 在 iPad 1 上崩溃,但在 iPad 2 或第 3 代上不会