0

I am working on a pdf Reader application.I am making use of CALayer to render the pdf contents.i employed swipe gesture to navigate across the pages.The issue is, if the user attempts to go to next or previous page once the rendering of layer has started,the 'going to next page' action is being performed after completion of rendering of the current pdf page on to the layer.I want the rendering of the current page to be stopped immediately as soon as the swipe occurred and next page should start rendering on the layer.any idea please help.

UPDate: here is my code

-(void)loadSinglePageWithWidth:(float)width andHeight:(float)height{
    draw=0;
    NSLog(@"before draw");
    [markupView.layer insertSublayer:renderingLayer1 above:tiledLayer1];
    loadingThread=[[NSThread alloc] initWithTarget:self selector:@selector(loadSinglePage) object:nil];
    [loadingThread start];
}
-(void)loadSinglePage{
    [renderingLayer1 setNeedsDisplay];
}

as soon as i swipe, in my action method, the code is written like

[loadingThread cancel];
[loadingThread release];
loadingThread=nil;

even i cancel the "loadingThread" the execution of the drawLayer: method seems to be running.am i correct with this thread approach?will drawLayer: code be executed by the thread which i am using to call setNeedsDisplay method?

4

1 回答 1

0

我认为最好的解决方案是在单独的线程中进行渲染。完成后,您只需在屏幕上显示渲染图像。如果没有,您可以随时取消操作。

于 2011-08-18T11:11:00.577 回答