开发者

UIButton events

开发者 https://www.devze.com 2023-01-20 09:27 出处:网络
using iphone SDK 4.0. I have some UIButtons in a viewcontroller which when touched should play a tone, and when released stop playing the tone. This is done so that the tone length depends on how long

using iphone SDK 4.0. I have some UIButtons in a viewcontroller which when touched should play a tone, and when released stop playing the tone. This is done so that the tone length depends on how long the button is held down.

I use the Touch down event for when i call [toneplay start] and the TouchUpInside event for when i call [toneplay stop].

A problem i have discovered is that if after touching a button i quickly navigate to another viewcontroller ( via tab bar button for example) the TouchUpInside event never fire开发者_开发百科s and so the tone never stops playing unless i navigate back to the screen and hit the same button.

What would be the correct way to do this, the actual method to play the tone doesn't matter here its more which UIButton events i should really be using to get the above functionality.

Thanks


You also want to hande UIControlEventTouchUpOutside and UIControlEventTouchCancel. Just think of touching the button, then moving the finger outside and liftig it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号