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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:13:13+00:00 2026-05-20T00:13:13+00:00

UIScrollView programming seems one of the hardest task to me :( I have subviews

  • 0

UIScrollView programming seems one of the hardest task to me 🙁

I have subviews in UIScrollView.
I want to let the subviews to take touch event first (and be dragged).
When subviews think it should relinquish touches and scroll should begin, it should be able to tell so to the scrollView.

I’ve experimented with touchesShouldCancelInContentView but this method only gets called once when scrollView thinks that user actually intended ‘scroll’.
I need to take control of when to cancel touch event for subviews not depend on internal uiscrollview’s implementation.

My best strategy so far is

subclass ScrollView

- (void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event
{
    SYSLOG(LOG_DEBUG, "MyScrollView touchesBegan");

    if (!self.dragging && self.isSubviewTouchable)
        [self.nextResponder touchesBegan: touches withEvent:event];

    [super touchesBegan: touches withEvent: event];
}

and from subView of scrollView

when subview needs to release the touch and let the scrollView to take touch events so on.

self.myScrollView.isSubviewTouchable = false;
[self touchesEnded: touches withEvent: event];

and in scrollView’s delegate class, I set the bool value back.

- (void) scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{   
    self.myScrollView.isSubviewTouchable = true;
}

Problem is, calling touchesEnded from the subview doesn’t actually release the touch event it seems.(the subview keeps getting dragged even after the touchesEnded call)
Also, I don’t see scrollView getting any touch event after the touchesEnded call which I hoped it would.

Any ideas?

Thank you

  • 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-20T00:13:14+00:00Added an answer on May 20, 2026 at 12:13 am

    I once tried solving this problem by using the PanGesture. To all the subviews you want to be draggable, you can probably add a UIPanGestureRegognizer and do whatever you want to do in their selector. That works well even inside ScrollView.

    UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(doSomething:)];
    [panGesture setDelegate:self];
    [subviewtoMove addGestureRecognizer:panGesture];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIScrollView with a UIView inside. I want to lock the x-axis
If I have a UIScrollView, and I want to zoom in on a location,
I have a UIScrollView which contains multiple UIImageViews. I want to know which UIImageView
I have UIScrollView with label. I am getting touch events coordinates. When user is
I have multiple ImageViews in a UIScrollView and I want to identify the specific
UIScrollView has a canceling mechanism, where it cancels the touch of subviews when it
I have UIScrollView with UIImageView on it. On UIImageView I have round marker(one more
I have a UIScrollView with pagingEnabled on and I want to (using like a
I have a UIScrollView with multiple subviews, each of which shows a page of
I have a UIScrollView wich contains 2 views the first at offset 0 and

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.