How to add sound while UIScrollview is scrolling in iphone sdk?

前端 未结 2 506
温柔的废话
温柔的废话 2020-12-12 08:11

This is my code for adding sound while UIScrollview is scrolling in iPhone SDK. In this code, how to add the sound while using touch-events in scrolling? Please give me your

相关标签:
2条回答
  • 2020-12-12 08:39

    you mast use UIScrollViewDelegate method

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
       //play sound here 
    }
    
    0 讨论(0)
  • 2020-12-12 08:40

    add UIScrollViewDelegate to your interface and then play sound while the scrolling is in task in scrollViewWillBeginDragging state and stop scrolling while in scrollViewDidEndDragging state.

    You can use AVAudioPlayer to play sound on iOS devices

    UPDATE:

    Tells the delegate when the scroll view is about to start scrolling the content.

    - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView

    Also, Tells the delegate when dragging ended in the scroll view.

    - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate

    Implement these in your code & put in your custom behavior

    0 讨论(0)
提交回复
热议问题