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

前端 未结 2 507
温柔的废话
温柔的废话 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: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

提交回复
热议问题