1
\$\begingroup\$

I am developing an iphone app. It has following page structure, 1.List of game levels in a UITableView 2.Game page

I use "UIViewAnimationTransitionFlipFromRight" between pages

Game page has 3 views, One is a scrollView in that my game grid is drawn. Game grid is a sub class of UIView ,that added to Scrollview. To support zooming i use CATiledLayer to draw the grid(20*20).

MY problem is GameGrid shows white or last played puzzles grid contents for a few seconds and then refresh(flashing) to the new content.

My GameGrid class as follows

`

 @implementation GameGrid

+(Class)layerClass
{    
 return [CATiledLayer class];
}

 - (id)initWithFrame:(CGRect)frame {   
        if ((self = [super initWithFrame:frame])) {
           CATiledLayer *tempTiledLayer = (CATiledLayer*)self.layer;
           tempTiledLayer.levelsOfDetail = 5;
           tempTiledLayer.levelsOfDetailBias = 2;        
              self.opaque=YES;  
           }
             return self;
}

-(void)drawRect:(CGRect)r
{
 //empty
}

-(void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context
{
 // here i am drawing grid
// filling rect
 // lines
// string etc..
}
\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

That's pretty much supposed to happen, it's doing (some of) the drawing in a thread.

It's been a while since I worked on this, but I used

@interface FastCATiledLayer : CATiledLayer
@end

@implementation FastCATiledLayer

+(CFTimeInterval)fadeDuration
{
    return 0.0;     // Normally it’s 0.25
}

@end

because I didn't like the forced initial delay. That may help.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.