开发者

drawLayer Method

开发者 https://www.devze.com 2023-02-12 18:39 出处:网络
I have drawLayer method, which i\'m calling from another method using setNeedsDisplay method, but the flow of code seems to be incorrect.

I have drawLayer method, which i'm calling from another method using setNeedsDisplay method, but the flow of code seems to be incorrect.

I have this method

  -(IBAction)makeSinglePageMode:(UIBu开发者_JAVA百科tton *)sender 

from where i'm calling another method

  -(void)loadSinglePageWithWidth:(float)width andHeight:(float)height

 which in turn calls `drawLayer` method.

I'm attaching the methods.I'm attaching only a part of code in these methods just to have more clarity while understanding the flow. After calling [tiledLayer1 setNeedsDisplay]; the flow comes back to makeSinglePageMode: method without executing drawLayer method. The next statement in makeSinglePageMode: method gets executed i.e. [self loadMarkUpFromPageDataSource:pd WithPageSize:pageSize inFrame:markupFrame]; I want this line of code to be executed only after drawLayer method execution is completed.

Any sort of help in this regard will be appreciated.

` -(IBAction)makeSinglePageMode:(UIButton *)sender{

GLogDebug(@"setting size of image to %@", NSStringFromCGSize(aspectFitSize));
[scrollView setContentSize:CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height - __TOP_BRANDING_BAR_HEIGHT)];

[markupView removeAllSubViews];
tiledLayer1.frame=CGRectMake(0,0,768,1024);

[self loadSinglePageWithWidth:(aspectFitSize.width) andHeight:aspectFitSize.height];

GLogDebug(@"markupFrame-%@", NSStringFromCGRect(markupFrame));
[self loadMarkUpFromPageDataSource:pd WithPageSize:pageSize inFrame:markupFrame];

}`

-(void)loadSinglePageWithWidth:(float)width andHeight:(float)height{

        [tiledLayer1 setNeedsDisplay];

}

`- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx

{

int c=[currentPage intValue]+1;

if(c==[kbDataSource numberOfPagesInBook]){
    tiledLayer2.hidden=YES;
}
else tiledLayer2.hidden=NO;



    }



    CGContextSetInterpolationQuality(ctx, kCGInterpolationHigh); 
    CGContextSetRenderingIntent(ctx, kCGRenderingIntentDefault);
    CGContextDrawPDFPage(ctx, myPageRef);

    CGContextRestoreGState(ctx);



}

}

0

精彩评论

暂无评论...
验证码 换一张
取 消