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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:45:27+00:00 2026-05-12T14:45:27+00:00

I have two horizontally scrolling UIScrollViews stacked vertically on top of each other within

  • 0

I have two horizontally scrolling UIScrollViews stacked vertically on top of each other within one ViewController. Each UIScrollView takes up half the screen. I am trying to independently track the position of both UIScrollViews.

I have successfully used this to track the position of the top UIScrollView:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView1 {

int Position = (scrollView1.contentOffset.x);

    if (Position == 0) {
    NSLog(@"Play A"); 
    }

    else if (Position == 280) {
    NSLog(@"Play B"); 
    }

//etc.
}

I would like to track the position of the bottom UIScrollView as well.

When I try to use this:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView2 {

int Position2 = (scrollView2.contentOffset.x);

if (Position2 == 0) {
NSLog(@"Play A2"); 
}

else if (Position == 280) {
NSLog(@"Play B2"); 
}

//etc.
}

I get an error that says “Redefinition of FirstViewConroller scrollViewDidScroll”.

So, determined to press on, I tried a rather hackish solution and attempted to use this instead:

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView2

{

int Position2 = (scrollView2.contentOffset.x);

if (Position2 == 0) {
NSLog(@"Play A2"); 
}

else if (Position2 == 280) {
NSLog(@"Play B2"); 
}

//etc.
}

The problem with this is that it triggers both methods when I move either of the UIScrollViews. For example — if I move the bottom UIScrollView 280 pixels (one image) to the right, the output I get in the console is:

PlayB
PlayB2

And if I move the top UIScrollView three images to the right the output I get is:

PlayC
PlayC2

Which doesn’t make any sense to me.

I think I may be bumping up against my own incomplete understanding of how delegates work. Within the viewDidLoad method I am setting both:

scrollView1.delegate = self;
scrollView2.delegate = self;

Perhaps this is part of the problem? Maybe I am causing trouble by declaring that both scrollViews have the same delegate? Just not sure.

I’ve also tried combining all of my conditional statements into one method — but I only want to track the position of the bottom UIScrollView when it moves and the position of the top UIScrollView when it moves, and putting the logic all in one method reports both positions when either one moves and this is not what I’m looking for.

Any help is appreciated. Would love to solve this particular problem, but would also really love to understand any bigger issues with how I’m approaching this. Still new at this. Keep thinking I’m getting the hang of it and then I run into something that stops me in my tracks..

  • 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-12T14:45:27+00:00Added an answer on May 12, 2026 at 2:45 pm

    This is exactly what the UIScrollView parameter is for. Create connections to scrollView1 and scrollView2 in IB and then do this:

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    
        if (scrollView1 == scrollView) {
            // Do stuff with scrollView1
        } else if (scrollView2 == scrollView) {
            // Do stuff with scrollView2
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to add two relative layouts next to each other horizontally in android.I
I have a ListBox with horizontal scrolling, and each item consists of a two
I have two QGraphicsView that are of equal width, one ontop the other in
I'd like to have one big scrollview with horizontal scrolling enabled. Within this scrollView
I have a very large horizontally scrolling UIScrollView which is reusing its subviews (moves
I have two labels that are stacked. If I want a horizontal line between
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two
I have two classes (MVC view model) which inherits from one abstract base class.
I have two columns: the left one is a Canvas containing an mx:Tree and
I have two divs that I need to position horizontally dependent on the width

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.