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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:02:09+00:00 2026-06-16T13:02:09+00:00

I have a UIScrollView and a UIPageControl in my iPad app. I’ve placed them

  • 0

I have a UIScrollView and a UIPageControl in my iPad app. I’ve placed them in the .xib file. My app supports landscape view only.

I try to set the width and height in code and it never looks right. I have a very simple case with 5 pages each set to a different color background to make sure my pages look right, but they never do, the colors overlap no matter what I do.

So my question is:

  1. How can I set the size right in code (viewDidLoad?)?
  2. Do I need to set the size for both UIScrollView and UIPageControl?

Thanks in advance.

  • 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-16T13:02:11+00:00Added an answer on June 16, 2026 at 1:02 pm

    Please check the code below. Here, I’ve done everything using code. Hope it can help you.

    int numberOfPages = 5 ;
    
    UIScrollView *scrollQuestionList = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height - 70.0)];
    scrollQuestionList.contentSize = CGSizeMake(numberOfPages*scrollQuestionList.frame.size.width, scrollQuestionList.frame.size.height);
    [self.view addSubview:scrollQuestionList];
    scrollQuestionList.backgroundColor = [UIColor clearColor];
    scrollQuestionList.delegate = self;
    scrollQuestionList.showsHorizontalScrollIndicator = NO;
    scrollQuestionList.pagingEnabled = YES;
    
    CGFloat x = 0.0;
    
    tagForBtns = 0;
    
    for (int i = 1; i <= numberOfPages; i++) 
    {
        UIView *contentView = [[[UIView alloc] initWithFrame:CGRectMake(x, 0.0, scrollQuestionList.frame.size.width, scrollQuestionList.frame.size.height)] autorelease];
    
        if (i%2 == 0)
        {
            [contentView setBackgroundColor:[UIColor grayColor]];
        }
        else
        {
            [contentView setBackgroundColor:[UIColor cyanColor]];
        }
    
        [scrollQuestionList addSubview:contentView];
        x+= scrollQuestionList.frame.size.width;
    }
    UIPageControl *pageCntrl = [[UIPageControl alloc] initWithFrame:CGRectMake(0.0, self.view.frame.size.height - 70.0, self.view.frame.size.width, 25.0)];
    pageCntrl.numberOfPages = numberOfPages;
    pageCntrl.backgroundColor = [UIColor clearColor];
    [pageCntrl addTarget:self action:@selector(clickedPageControl:) forControlEvents:UIControlEventValueChanged];
    pageCntrl.currentPage = 0;    
    [self.view addSubview:pageCntrl];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIScrollView and a UIPageControl on my View in my iPhone app.
I have UIScrollView on xib-file on portrait mode. When I run the application and
I have UIScrollView and number of objects (UIView compositions) with UIImageViews inside them. Some
I have UIScrollView in my view. Problem is that if I slightly scroll it
I have UIScrollView added to the main window of the app with IB. What
I have a UIScrollView that nests a UIImage and several symbols that are placed
I have a UIScrollView . This scroll view scrolls my custom GameView . When
I have a UIScrollView which contains 12 buttons. Only 5 buttons are visible at
I have UIScrollView where placed elements(elements placed from the top to down), how can
I have a UIScrollView as a child to a ViewController.view and for some reason

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.