Frage

I have an UIScrollView with drawing on it's content view. I also have zoom functionality. I am adding UIView with UITextViews as its subview on zoom and removing UIView with UITextViews when user pinch out zoom. Sometimes it works fine but sometimes its crashing.

Also console continuous shows different combinations of these and more :

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

I have attached a screenshot of the instrument with zombies template. Which shows the summary of message sent to deallocated object.

enter image description here

Some of my code which will useful for solving this problem. I am returning CATiledLayer to ensure zoomed content is sharp.

- (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];
}
War es hilfreich?

Lösung

May be i'm wrong but, why do you instantiate a CATiledLayerin the dealloc method, this is physically wrong... From what i know the reason of this error is either you are trying to dealloc an already deallocated object, or the object you are deallocating is empty

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top