滚动视图滚动时如何播放取决于滚动视图滚动速度的声音?
我添加了一个滚动视图,它水平滚动。当我的滚动视图滚动时,我必须播放声音。为此,我在
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
AudioServicesPlaySystemSound(_scrollPewSound);
}
方法中播放了我的音乐文件。 我的问题是我必须播放取决于滚动视图滚动速度的声音。这意味着如果用户快速滚动,则音乐应该播放得快,如果滚动视图滚动得慢,则音乐应该播放得慢。
如果我实现这个方法:-
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
AudioServicesPlaySystemSound(_scrollPewSound);
}
那么当滚动视图滚动时音乐就会播放。
所以这两种效果都达不到要求。
请建议我如何实现这一点。
I have added a scroll view and it scrolls horizontally.I have to play a sound when my scrolls view scrolls.For that I played my music file in
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
AudioServicesPlaySystemSound(_scrollPewSound);
}
method.
My problem is that I have to play a sound that is dependent on scroll view scrolling speed.Means if user has scroll fast the music should play fast and if the scroll view have scrolled slow the music should play slow.
If I implement this method:-
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
AudioServicesPlaySystemSound(_scrollPewSound);
}
then the music play just when the scroll view gets scrolled.
So these both effects are not fulfill the requirement.
Please suggest me how to implement this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有包含“scrollspeed”的属性,但也许,您可以将scrollview.contentOffset保存在某个变量中,然后以一定的延迟启动计时器,再次检查偏移量并计算“scrollspeed”?
There are no property, containing "scrollspeed", but maybe, you can save you scrollview.contentOffset in some variable, then start timer with some delay, which check offset again and calculate "scrollspeed"?