问题
I am developing an pdf reader in which i have to load each page of the pdf book on finger swipe. For each swipe i am incrementing one page it is working fine if i am swiping slowly.where it is not at all working if the swipe is so fast it gets crashed.
hi folks i resolved the above issue with the NSobject class reference it has only two lines..
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(loadPagesAccordingToCurrentOrientation) object:nil];
[self performSelector:@selector(loadPagesAccordingToCurrentOrientation) withObject:nil afterDelay:0.5];
回答1:
I cant be sure but It feels like you are not accounting for the use case where one page may not have finished rendering while another comes into the pipe.
The line in
loadSinglePageWithWidth:(float)width andHeight:(float)height
myPageRef = CGPDFDocumentGetPage(...
feels especially unstable even if wrapped in the @synchronised pragma.
I think you need to account for that situation and cancel any existing renderings/animations before allowing the next one to begin.
SO isnt a debugger.
回答2:
some of the code is used for my problem
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(loadPagesAccordingToCurrentOrientation) object:nil];
[self performSelector:@selector(loadPagesAccordingToCurrentOrientation) withObject:nil afterDelay:0.5];
来源:https://stackoverflow.com/questions/4848414/problem-when-swipe-using-very-fast