Sometimes, interruptions such as phone call occur and disturb a regular behavior of an app in iPhone or iPad.
For example, I created one UIScrollView instance and implemented UIScrollView delegate methods: scrollViewWillBeginDragging and scrollViewDidEndDragging(and scrollViewDidEndDecelerating).
A scrollViewWillBeginDragging method deactivated all custom buttons in my app. Then scrollViewDidEndDragging and scrollViewDidEndDecelerating methods activated these custom buttons. That is, while the user scrolled, all custom buttons became deactivated for a while.
The problem was that while the user started to drag and just held an UIScrollView instance, if I took a screenshot by pressing a home button and a power button, then any of scrollViewDidEndDragging and scrollViewDidEndDecelerating didn't get called. So the app became messed up.
I implemented a UIApplicationWillResignActiveNotification method in my UIViewController, but it didn't get called after taking a screenshot.
How can I catch any kind of interruption that disturbs a regular flow of events?
Sometimes, touchesEnd and touchesCanceled didn't get called too due to an interruption.
Thank you.
I faced the same problem and got rid of it by using performSelector:withObject:afterDelay
method of NSObject.
In scrollViewDidScroll:
[NSObject cancelPreviousPerformRequestsWithTarget:yourController];
[yourController deactivateButtons];
[yourController performSelector:@selector(activateButtons) withObject:nil afterDelay:0.5];
You can try this technique and combine it with other that you mentioned.
Hope, that will help. Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With