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 6676831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:02:29+00:00 2026-05-26T04:02:29+00:00

Im working with an UIScrollView subclass and im just trying to catch a particuliar

  • 0

Im working with an UIScrollView subclass and im just trying to catch a particuliar event but i am at a loss as to how to approach it.
basically i have a horizontal uiscrollview and it has bouncing turned off. when i scroll to the either end of the scroll view it should stop dead which it does. but now i want to catch an event if the user tries swiping in the direction of the currently occupied end of content. i.e. if the user scrolls all the way to the right and tries to swipe right again how do i catch this gesture.

I have tried adding gesture recognisers to the uiscrollview subclass and when it reaches the end it turns off scrolling enabled which allows these gestures to be caught. But if the user tries to swipe in the direction that is available the scrolling effect wont happen as scrolling is turned off. i.e. when the user has scrolled to the right, then tries to scroll back to the left nothing will happen as scrolling was turned off to catch a possible gesture to the right.

Any ideas on how to catch an attempt to scroll in a particuliar direction?
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-26T04:02:30+00:00Added an answer on May 26, 2026 at 4:02 am

    One way to catch that event is by setting the bounces to property YES and implementing the stopped bounce yourself in a scrollview subclass. By overriding the setContentOffset methods, you can replace the coordinate it scrolls to. When this happens, you can let other things happen as well.

    -(void)setContentOffset:(CGPoint)contentOffset
    {
        CGPoint validOffset = [self validVersionOfOffset:contentOffset];
    
        if(contentOffset.x == validOffset.x)
        {
            [super setContentOffset:validOffset];
        }
        else
        {
            [super setContentOffset:validOffset animated:NO];
            [bounceCatchDelegate scrollViewTriedBouncing:self];
        }
    }
    
    -(void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
    {
        CGPoint validOffset = [self validVersionOfOffset:contentOffset];
        [super setContentOffset:validOffset animated:animated];
        if(contentOffset.x == validOffset.x)
        {
            [super setContentOffset:validOffset animated:animated];
        }
        else
        {
            [super setContentOffset:validOffset animated:NO];
            [bounceCatchDelegate scrollViewTriedBouncing:self];
        }
    }
    
    -(CGPoint)validVersionOfOffset:(CGPoint)offset
    {
        //Prevents bouncing at the left and right:
        offset.x = fminf(offset.x, self.contentSize.width-CGRectGetWidth(self.frame));
        offset.x = fmaxf(offset.x, 0.0f);
        return offset;
    }
    

    The usage of a delegate is only a suggestion, any method call would work.

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

Sidebar

Related Questions

I am trying this code on UIScrollView but it's not working. The NSLog is
I have a uisegmentedcontrol within a horizontally scrolling uiscrollview. The scrollview is working just
So I have a UIViewController subclass called MyTabBarViewController that has a UIScrollView. Inside of
I have a CATiledLayer inside a UIScrollView and all is working fine. Now I
I'm working on a app that has a paging UIScrollView that contains three scrollViews
I'm using UIScrollView and using scrollRectToVisible:animated This is working fine for me. But I
I'm working on a kiosk style slideshow app. I have a UIScrollView which shows
I'm working on an iPhone game, and trying to use a UIScrollView to display
I have a subclass of UIScrollView that I'm using for images slideshow, with infinite
I have successfully implemented a working UIScrollView layer on top of Cocos2d using this

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.