I have an issue in my project where a UIView animation does not resume from the point when the home button was pressed.
These are the steps (simplified example for discussion):
1) I have a simple project with an app delegate h&m files and a single view controller
2) In the xib, I have a UIView which is set with alpha=0
3) In the viewdidload of view controller, i am doing an animation as follows:
[UIView animateWithDuration:20.0 animations:^{_testView.alpha = 1.0;}];
4) This works fine - in 20 seconds, the view gets gradually visible fully (as expected)
The issue is when I press the home bottom in between - say 5 seconds from the start of animation - if I return to the app immediately after home key press, the animation does not start from the point where the home screen was pressed - instead it loads a fully visible view.
This is what I did to resolve this:
1) Created local notification from app delegate. - In applicationDidEnterBackground: for pausing and in applicationDidBecomeActive: for resuming animation
2) In the view controller, I am checking for the local notifications and based on that doing resume layer and pause layer (as per apple recommended pauselayer and resumelayer methods with CALayer object)
3) Checked in debug mode with breakpoints - the control is going into the pause and resume methods as expected
4) But, end result is not as expected - always the view loads with the animation fully committed
I suspect no matter what I do, the view gets loaded with a committed animation of alpha=1.0 ;
Can some one give me pointers in resolving this ; Checked other SO posts for pause/resuming animations - nothing helped.
Essentially I want to re-start the animation from the point I pressed the home button
Thanks