在iPhone中滚动UITableView时,NSTimer会受到干扰 [英] NSTimer gets disturbed while scrolling the UITableView in iphone

查看:42
本文介绍了在iPhone中滚动UITableView时,NSTimer会受到干扰的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里遇到了一个奇怪而罕见的问题.我正在使用NSTimer事件,该事件在100ms反复播放声音.我在同一个类中有UITableView.当我滚动tableview时,计时器会受到干扰.我的意思是滚动tableview时反复播放的声音变得不规则.这不会在模拟器中发生.在设备上测试时会发生此问题.(我使用iphone3G)

I have got a strange and rare problem here. I am using NSTimer event that play sound repeatedly at 100ms. I have UITableView in same class. When i scroll the tableview the timer gets disturbed. I mean the sound which was playing repeatedly becomes irregular while scrolling tableview. This does not happen in simulator. This problem happens while testing on device. (I use iphone3G)

推荐答案

NSTimer在调用的同一线程上工作.因此,如果您在主线程(所有UI都在其中工作)上执行此操作,则计时器可能会错过某些触发事件,因为会进行一些密集的UI渲染.

NSTimer works on the same thread it was invoked. So if you do this on the main thread (where all UI works), the timer can miss some of it's fires because some intensive UI rendering takes place.

我建议您在单独的线程上播放声音.

I suggest you to play sound on a separate thread.

阅读此书可获得更深入的了解:

Read this for more in-depth understanding: link

这篇关于在iPhone中滚动UITableView时,NSTimer会受到干扰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆