简体   繁体   中英

NSTimer gets disturbed while scrolling the UITableView in iphone

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 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM