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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:26:48+00:00 2026-06-17T09:26:48+00:00

I am attempting to make a basic scroll view with a connected page control,

  • 0

I am attempting to make a basic scroll view with a connected page control, and I have run into some problems with my code. My viewDidLoad method looks like this:

- (void)viewDidLoad{
[super viewDidLoad];
NSLog (@"View did load");
// Do any additional setup after loading the view, typically from a nib.

scrollView.delegate = self;
scrollView.pagingEnabled=YES;

NSArray *frames = [NSArray arrayWithObjects:[UIColor redColor], [UIColor greenColor], [UIColor blueColor], nil];
for (int i = 0; i < frames.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 = [frames objectAtIndex:i];
    [self.scrollView addSubview:subview];
    NSLog (@"Looped, i = %i color = %@", i, [frames objectAtIndex:i]);
}

self.scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * frames.count, scrollView.frame.size.height);
NSLog(@"The width is: %f", self.scrollView.frame.size.width);
}

The problem seems to be that the coloured frames I attempt to add to the view never appear (not even the first one). If I didn’t have ARC enabled, I would have released the CGRect frame at the end of each loop, but it really should do that itself with ARC, right?

When I run the app, both in the simulator and on my actual phone, I get a black screen with the UIPageControl dots at the bottom. When I swipe my finger across the ScrollView nothing happens, but if I pull it very far to one side, the pageControl moves to the next “dot”.

The last NSLog sentence always outputs 0.0000, indicating that none of the views have been added to the scroll view.

All help is very appreciated 🙂

  • 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-17T09:26:49+00:00Added an answer on June 17, 2026 at 9:26 am

    The problem is doing it in viewDidLoad. Move your code to viewDidAppear: and it should work fine. Frames are not yet set in viewDidLoad.

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

Sidebar

Related Questions

I was attempting to make some expression templates as an answer to this question
I'm attempting to make a StateMachine execute some database action between states. So I
I am attempting to make a registration-like page for a small forum. To register
I am attempting to make a maven parent pom setup where I don't have
I'm attempting to make a basic game in cocos2d, and I've gotten to the
I am attempting to add validation to my application. I have some rules I
I'm attempting to make use of the Beanstalk (beanstalkapp.com) API by pulling data into
I'm attempting to make a custom control that properly draws itself to fill its
I am attempting to make a basic game which requires a serious of buttons
I am attempting to compile a basic array wrapper template class into a .o

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.