I'm trying to implement a page flipping animation - which works, when the user doesn't navigate too fast through the pages.
My code looks like this:
[CATransaction begin];
[CATransaction setAnimationDuration:duration];
[CATransaction setCompletionBlock:^{
if (pageDifference == 1 && setDelegate) {
[self cleanupFlip];
self.animationInProgress = NO;
}
}];
flipAnimationLayer.transform = endTransform;
[CATransaction commit];
The endTransform
is a CATransform3DIdentity
, which, as I said, works fine. In my cleanupFlip
I'm preparing the screenshot for the next page, which enables me to perform the page flipping animation. And the screenshot I'm makiing seems to be the problem; as soon as the user clicks to fast through the pages, the animation doesn't happen but the pages just change - without page flipping animation. I got an improvement through setting a flag animationInProgress
which avoids starting the next animation before the old finishes.
What I don't get: I'm expecting to work this fine, as I'm setting the animationInProgress
flag at the very end of the animation, so everything should be prepared for the next run - but it isn't...
On the simulator I can click faster than on the device - there I have to wait for a second until I can start the next page turn.
Without making the screenshot (e.g., just using an empty image), everything works as expected. It seems as if it's a problem if the cleanupFlip
takes some time.
Any ideas how I could make this work?
Thanks a lot!