Hello all.

I have a problem, Im encoding many subviews of class CustomUIView,
each of it  draws a CGImageRef, now, the encoding part its great,
fast.  Also decoding,

It decodes great each sub class. but then when I add the custom view
to the parent view the nightmare starts.

this is my method that unarchive the subviews and then add each one to
the parent view:


-(void)unarchiveItemsInScene:(NSKeyedUnarchiver *)unarchiver{
        
        NSDictionary * itemsDic = [[unarchiver
decodeObjectForKey:@"BCItemsInSceneKey"] retain];
        [self setBc_background:[unarchiver
decodeObjectForKey:@"BCSceneBackgroundKey"]];
        [bc_bgImageview setNeedsDisplay];
        [unarchiver finishDecoding];
        //Adding the elements to the scene
        //Organizing the keys so the order will be constant
        NSArray * keys =[self bubbleSortDictionaryByKeys:itemsDic];
        for (NSString * actualKey in keys) {
                BCItemView * item = [itemsDic valueForKey:actualKey];
                item.bc_parentScene = self;
                [bc_itemsView addSubview:item];
        }
        [itemsDic release];
        bc_sceneHasChanges = NO;
        [self setNeedsDisplay];
        
}


and this is the drawrect method of the BCItemView

// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code.
        
        CGContextRef context = UIGraphicsGetCurrentContext();   
        CGContextSaveGState(context);
        CGContextTranslateCTM(context, 0, CGImageGetHeight(bc_itemImage));
        CGContextScaleCTM(context, 1.0, -1.0);
        CGContextDrawImage(context, self.bounds, bc_itemImage);
        CGContextRestoreGState(context);

}

Running Time profiler, its telling me that the 100% of time its spend
on the CGContextDrawImage method.

So the symptoms are :  I encode the superview's BCItemsView ( which
can be mane many or not) if they aren't many subviews the loading
process is done fast. BUT they are many, the app decodes fast, and I
see the a progress indicator showing the values as expected, but
suddenly everything seems to freeze and it takes a long time like 15
-20 seconds until the whole Parent view displays all its superviews.

is there anything I can do in order to improve the drawing
performance, or at least be able to keep progressing the indicator to
show the user that something is running? because this last thing I
tried but the progress indicator just disappears.. or doesn't' move at
all.

Thank you very much for any help.

Regards
Gustavo
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to