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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:20:49+00:00 2026-05-25T22:20:49+00:00

I found a great tutorial online that shows you how to page through different

  • 0

I found a great tutorial online that shows you how to page through different pages, well kind of. Here is the link to the tutorial here: http://www.iosdevnotes.com/2011/03/uiscrollview-paging/

The question I have is, how can I tweak his code so that instead of loading “colors” it loads different independent views or view controller files I create? Like I see it loads it’s information from the NSArray, but how do you code it so that you include views or view controllers inside that array, and do you have to add anything else special to make this happen?

Here is the code I’m referring to from his tutorial which is in the implementation file:

- (void)viewDidLoad {
    [super viewDidLoad];

    pageControlBeingUsed = NO;

    NSArray *colors = [NSArray arrayWithObjects:[UIColor redColor], [UIColor greenColor], [UIColor blueColor], nil];
    for (int i = 0; i < colors.count; i++) {
        CGRect frame;
        frame.origin.x = self.scrollView.frame.size.width * i;
        frame.origin.y = 0;
        frame.size = self.scrollView.frame.size;

        UIView *subview = [[UIView alloc] initWithFrame:frame];
        subview.backgroundColor = [colors objectAtIndex:i];
        [self.scrollView addSubview:subview];
        [subview release];
    }

    self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * colors.count, self.scrollView.frame.size.height);

    self.pageControl.currentPage = 0;
    self.pageControl.numberOfPages = colors.count;
}
  • 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-25T22:20:49+00:00Added an answer on May 25, 2026 at 10:20 pm

    As a quick thought, you could try creating an array or similar of views instead of colours.

    Then in the for loop get the views out of the array and use this in the addSubView: message.

    This would work for a few views but would not scale well.

    I do something similar to this but with UIImageViews to be able to scroll a few images.

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

Sidebar

Related Questions

I found a great walk-through for Sync Framework here: http://msdn.microsoft.com/en-us/library/bb726010.aspx But, it is using
I have just found this great tutorial as it is something that I need.
I found a great tutorial on performing a faceted search. http://www.devatwork.nl/articles/lucenenet/faceted-search-and-drill-down-lucenenet/ This article does
I'm using the popular restful authentication app/tutorial found here: http://railsforum.com/viewtopic.php?pid=74245#p74245 I have been using
I found this great tutorial for extending GMarkers in v2 google maps: http://www.googlemapsbook.com/2007/01/22/extending-gmarker/ Unfortunately,
I found a great C++/ODBC example here ... The project I downloaded builds great
I've found a great datepicker on EveryBlock's web site: http://ui-patterns.com/userset/553/image/2955#focus Does anybody know which
A while back a found a great-looking framework that allowed .net developers to implement
In .Net, I found this great library, HtmlAgilityPack that allows you to easily parse
I have found this great tutorial, about uploading files with a Flex app, using

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.