In My iphone Application,I am doing simple image animation in a View and in that same View i have WebView in which i am showing HTML.i have done that animation by making the infinite calls of my animation code(animationMethodA),i am doing this by setting the NSTimer.My Problem is that when i scroll the WebView then same time That animating Image get stopped and that animating image remains in rest stage(stopped) until i stopped scrolling the webView.As i stop Scrolling the WebView Animation starts itself.Actually i got the Reason of that Problem.at the time of scrolling the WebView time(NSTimer) not call that animationmethodA method.
Please let me What should i do for that problem?.
Thanks.
Finally i got the Solution for my Question.
I have to add the timer to another
RunLoopMode, Per default a timer is added to theNSDefaultRunLoopMode. That means that the timer is only executing when the app’s run loop is inNSDefaultRunLoopMode.Now, when a user touches the screen (e.g. to scroll a
UIScrollView) the run loop’s mode will be switched toNSEventTrackingRunLoopMode. And now, that the run loop is not inNSDefaultRunModeanymore, the timer will not execute. The ugly effect of that is, that timer is blocked whenever the user touches the screen. And that can be a long time when the user is scrolling, because the timer is blocked until the scrolling completely stops. And when the user continues to scroll, the timer is blocked again.Fortunately the solution to this problem is quite simple: You can add your timer to another
NSRunLoopMode. When add the timer toNSRunLoopCommonModesit will execute in all run loop modes (that have been declared as a member of the set of “common” modes, to be precise). That means that the timer is not only working inNSDefaultRunLoopModebut also inNSEventTrackingRunLoopMode(when the user touches the screen).So after you initialize your timer, add it to
NSRunLoopCommonModes:[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];I got this answer form this link
I hope this may helpful to someone…!!!