消息发送到解除分配的对象'_UITextTiledLayer'对象

时间:2014-05-14 14:23:25

标签: ios objective-c uiview uiscrollview

我有UIScrollView的图纸内容视图。我也有缩放功能。我在UIView添加UITextViews作为缩放的子视图,并在用户缩小缩放时将UIViewUITextViews一起删除。有时它工作正常但有时会崩溃。

此外,控制台连续显示这些以及更多的不同组合:

CALayerGetSuperlayer called on instance of UIScrollViewDelayedTouchesBeganGestureRecognizer
CALayerGetSuperlayer called on instance of __NSCFDictionary
CALayerGetSuperlayer called on instance of __NSArrayM
CALayerGetSuperlayer called on instance of __NSCFString
CALayerGetSuperlayer called on instance of __NSCFType

我附上了僵尸模板的仪器截图。其中显示了发送到解除分配对象的消息摘要。

enter image description here

我的一些代码可用于解决此问题。 我正在返回CATiledLayer以确保缩放的内容非常清晰。

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {
        CATiledLayer *tiledLayer = (CATiledLayer *)[self layer];
        tiledLayer.levelsOfDetail = 4;
        tiledLayer.levelsOfDetailBias = 4;
    }
    return self;
}

+ layerClass
{
    return [CATiledLayer class];
}

- (void)dealloc
{
    CATiledLayer *tiledLayer = (CATiledLayer *)self.layer;
    tiledLayer.contents=nil;
    tiledLayer.delegate=nil;
    [tiledLayer removeFromSuperlayer];
}

1 个答案:

答案 0 :(得分:1)

可能我错了,但是,为什么要在CATiledLayer方法中实例化dealloc,这在身体上是错误的...... 据我所知,这个错误的原因是你试图解除已经解除分配的对象,或者你要解除分配的对象是空的