NSTimer gets disturbed while scrolling the UITableView in iphone

耗尽温柔 提交于 2019-12-12 06:26:24

问题


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)


回答1:


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



来源:https://stackoverflow.com/questions/5186641/nstimer-gets-disturbed-while-scrolling-the-uitableview-in-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!