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

  • Home
  • SEARCH
  • 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 9109603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:04:55+00:00 2026-06-17T03:04:55+00:00

For my iPad App, I have a main ViewController which contains two UIScrollviews and

  • 0

For my iPad App, I have a main ViewController which contains two UIScrollviews and a UIPageControl.
The Problem is that the delegates for the paging are not getting called.
Here is the layout:

enter image description here

Selecting a button in the lower thumbScrollView needs to update the image in the mainScrollView (this works) Swiping the thumbScrollView or picking a dot on the pageControl needs to “page” the thumbScrollView to show the next previous set of buttons. The swiping does not work because the delegate functions are just not getting called.

I declare the scrollviews and pagecontrol as follows in my VC

@property (strong, nonatomic) IBOutlet UIScrollView *mainScrollView;
@property (strong, nonatomic) IBOutlet UIScrollView *thumbScrollView;
@property (strong, nonatomic) IBOutlet UIPageControl *pageControl;

The ViewController implements UIScrollViewDelegate

@interface MyViewController : UIViewController<UIScrollViewDelegate>

And I implement the following UIScrollViewDelegate delegate functions in my VC’s .m file.

- (void)scrollViewDidScroll:(UIScrollView *)sender;
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;

The view appears but when I swipe across the buttons I do not see the delegate functions above getting called.

I have not found a solution to this in StackOverflow although I have factored in advise from other related posts for other aspects of this (ex. the logic to distinguish which scrollview has initiated the action etc)

ADDING DETAILED CODE HERE (as requested by @HeWas)

This is the header file for the Main View Controller that controls the two scrollviews and pagecontrol (RELEVANT EXCERPTS – TELL ME IF YOU NEED MORE)

// ImageBrowseViewController.h
// (NOTE - In Interface Builder I have added a tag attribute of 0 to mainScrollView
//  and 1 to thumbScrollView, to enable me to distinguish which scrollView the delegate 
//  needs to respond to)



#define TAG_MAIN_SCROLLVIEW 0
#define TAG_THUMB_SCROLLVIEW 1

@interface ImageBrowseViewController : UIViewController<UIScrollViewDelegate>
{
    UIButton* currentlySelectedButton;
    UIScrollView *mainScrollView;
    UIScrollView *thumbScrollView;
    UIPageControl* pageControl;
    BOOL pageControlBeingUsed;

}

@property (strong, nonatomic) IBOutlet UIScrollView *mainScrollView;
    // … connected as outlet in IB to mainScrollView
@property (strong, nonatomic) IBOutlet UIScrollView * thumbScrollView;
    // … connected as outlet in IB to thumbScrollView
@property (strong, nonatomic) IBOutlet UIPageControl *pageControl;
    // … connected as outlet in IB to pageControl


…
-(IBAction)changePage; //Touch up Inside IBAction connected to pageControl


…
@end

This is the implementation file for the Main View Controller that controls the two scrollviews and pagecontrol (RELEVANT EXCERPTS – TELL ME IF YOU NEED MORE)

//
//  ImageBrowseViewController.m
//

    …
@synthesize mainScrollView;
@synthesize thumbScrollView;
@synthesize pageControl;


// UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)sender {

    if ( [sender tag] == TAG_THUMB_SCROLLVIEW ) {
        // This is the thumbScrollview
        // Update the page when more than 50% of the previous/next page is visible

        CGFloat pageWidth = self.thumbScrollView.frame.size.width;
        int page = 
            floor((self.thumbScrollView.contentOffset.x - pageWidth / 2) / pageWidth) 
            + 1;
        self.pageControl.currentPage = page;

    }
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
    pageControlBeingUsed = NO;
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    pageControlBeingUsed = NO;
}

- (IBAction)changePage {
    // Update the scroll view to the appropriate page
    CGRect frame;
    //frame.origin.x = self.scrollView.frame.size.width * self.pageControl.currentPage;
    frame.origin.x = self.thumbScrollView.frame.size.width * self.pageControl.currentPage;

    frame.origin.y = 0;
    frame.size = self.thumbScrollView.frame.size;
    [self.thumbScrollView scrollRectToVisible:frame animated:YES];

    // Keep track of when scrolls happen in response to the page control
    // value changing. If we don't do this, a noticeable "flashing" occurs
    // as the the scroll delegate will temporarily switch back the page
    // number.
    pageControlBeingUsed = YES;
}
  • 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-06-17T03:04:57+00:00Added an answer on June 17, 2026 at 3:04 am

    You code all looks 100% (aside from this typo: @synthesize floorplanThumbScrollView;, but that isn’t your problem).

    I am sure that the answer is that you have not correctly wired your scrollview DELEGATES in IB.

    This is the clue:

    “Yes I have set all three in Interface Builder. So mainScrollView, thumbScrollView, and pageControl are wired in IB to the above declarations in the VC’s .h file.”

    You need 2 connections between your ViewController and your scrollViews.

    (1) ctrl-drag FROM viewController TO scrollView, connect to IBOutlet property.
    This is what you have done.

    (2) ctrl-drag FROM scrollView TO viewController, connect to delegate.
    I do not think you have done this.

    Explanation of step 2

    UIScrollView has a built-in property called ‘delegate’. The scrollView uses this property to send messages to it’s delegate. You set this delegate in interface builder (step 2) or you can do it in code. For example in your viewController you could do this:

        [myScrollView setDelegate:self];
    

    which would set the viewController as the delegate for myScrollView. If you do it by linking in Interface Builder you don’t need this code (and IB doesn’t create any).

    Either way what this actually does is set scrollView’s delegate iVar to a pointer to the viewController. The great thing about using delegates like this is that the delegator (UIScrollView) doesn’t have to know anything about the delegatee (in this case your UIViewController). This allows us to reuse UIScrollView so long as we observe it’s delegate protocol.

    Whenever the scrollView needs to notify it’s delegate, internally it sends a message like this..

        [self.delegate scrollViewDidScroll:self];
    

    (you don’t see that, it’s in the scrollView’s implementation).

    The object that you have set as the delegate to scrollView needs to implement all of the required methods that the scrollView’s delegate protocol declares, and can choose to implement any of the optional delegate methods. Here is the protocol

    To work out which methods are required, read the UIScrollView class reference, which tells you this:

    The UIScrollView class can have a delegate that must adopt the UIScrollViewDelegate protocol. For zooming and panning to work, the delegate must implement both viewForZoomingInScrollView: and scrollViewDidEndZooming:withView:atScale:; in addition, the maximum (maximumZoomScale) and minimum (minimumZoomScale) zoom scale must be different.

    Everything else in the protocol is optional.

    This delegate pattern is one you can easily implement yourself for your own object reuse, and is one of the most common ways of passing messages between decoupled objects in objective-C.

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

Sidebar

Related Questions

For my iPad App, I have a main ViewController which contains two UIScrollview s
I have a iPad app which is NOT modified for the new iPad with
Building an iPad app. I have a button on my main view that I
If I'm creating a universal iPhone/iPad app, I have two XIBs. One main XIB
I have an iPad app with a main ViewController, and inside of it I
In my iPad app I have two textfields. One displays the normal, default textfield
I currently have one iPad app, but it now needs to become two. The
I have an iPhone/iPad app which play a HTTP Live Stream of a tv
I have an iPad app that uses custom fonts though the UIAppFonts elements in
I have an iPad app which has a funky Path-style menu which is present

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.