我有drawLayer方法,我使用setNeedsDisplay方法从另一个方法调用,但代码流似乎不正确。
我有这个方法
-(IBAction)makeSinglePageMode:(UIButton *)sender
从哪里我称之为另一种方法
-(void)loadSinglePageWithWidth:(float)width andHeight:(float)height
which in turn calls `drawLayer` method.
我正在附加方法。我只是在这些方法中附加了一部分代码,只是为了在理解流程时更加清晰。 调用[tiledLayer1 setNeedsDisplay]后;流程返回到makeSinglePageMode:方法而不执行drawLayer方法。 makeSinglePageMode:方法中的下一个语句被执行,即[self loadMarkUpFromPageDataSource:pd WithPageSize:pageSize inFrame:markupFrame]; 我希望只有在drawLayer方法执行完成后才能执行这行代码。
在这方面的任何形式的帮助将不胜感激。
` - (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);
}
}