Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 769483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:20:35+00:00 2026-05-14T18:20:35+00:00

I have a scroll view that can be scrolled to the sides (only left

  • 0

I have a scroll view that can be scrolled to the sides (only left and right, not up and down).
I want to play a short sound (less than a second) whenever the scroll view is moved X pixels to either side.

How can this be done? Code samples will be greatly appreciated…

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:20:36+00:00Added an answer on May 14, 2026 at 6:20 pm

    Here is the code I used:

    I added the SoundEffect.h and SoundEffect.m files to my project (you can find them online).
    Then, I created a sound effect instance:

    SoundEffect *soundEffect;
    

    Then, I setup my UIViewController as the delegate of my UIScrollView by adding <UIScrollViewDelegate> to the .h file of the view controller and setting the relevant outlet of the UIScrollView.

    In the -(void)viewDidLoad method, I initialized my sound effect:

    NSBundle *mainBundle = [NSBundle mainBundle];
    soundEffect = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle pathForResource:@"Tik" ofType:@"wav"]];
    

    And then, I implemented these two methods:

    #pragma mark -
    #pragma mark Scroll View Delegate Methods
    
    - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
    {
        lastScrollPosition = scrollView.contentOffset.x / 55;
    }
    
    - (void)scrollViewDidScroll:(UIScrollView *)scrollView
    {   
        if ((int)(scrollView.contentOffset.x / 55) != lastScrollPosition1)
        {
            lastScrollPosition1 = scrollView.contentOffset.x / 55;
            [soundEffect1 play];
        }
    }
    

    I needed the sound effect to fire every 55 pixels to either direction, but you can change this to a constant value that fits your needs.
    It works great for me, and hopefully, it will help others as well…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a scroll view in my application and i want that when the
I have a java applet that loads up a scroll view that you can
I know that ScrollView can have only one Child but in my case I
I have a scroll view with transparent background that covers most of the screen.
I have UIScrollView in my view. Problem is that if I slightly scroll it
I want to have a custom view at the top of my UITextView that
I have a list view that can display items based on internal state (it
I have custom view in my application which can be scrolled by the user.
I have a split view-based app that presents a master-detail interface, and uses a
I'm trying to make a timeline view that shows events as UIButtons that can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.