problem when swipe using very fast

依然范特西╮ 提交于 2020-01-23 20:07:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!