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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:52:05+00:00 2026-06-10T11:52:05+00:00

In my view contoller’s viewDidLoad function, I have this guy: UIScrollView *scroller = [[UIScrollView

  • 0

In my view contoller’s viewDidLoad function, I have this guy:

UIScrollView *scroller = [[UIScrollView alloc] initWithFrame:self.view.frame];
scroller.contentSize = self.view.frame.size; // Tried w/ and w/o this
scroller.showsVerticalScrollIndicator = YES; // Tried w/ and w/o this

for (int x = 0; x < 10; x++) {
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, x * 100, 100, 100)];
    label.text = [NSString stringWithFormat:@"%i label", x];
    [scroller addSubview:label];
}

[self.view addSubview:scroller];

It shows the first 8 labels OK, but the scroll view won’t… scroll. It is just cut off. Any idea why?

  • 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-10T11:52:07+00:00Added an answer on June 10, 2026 at 11:52 am

    It won’t scroll because your contentSize is only set to the same size as the scrollview itself. The contentSize is the size of the scrollable area that the scrollview acts as a window in to. You need to set it wide enough to actually see your labels.

    Based on your current code, your final label is in rect {0, 900, 100, 100}, so your contentSize needs to be at least CGSizeMake(100, 1000).

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

Sidebar

Related Questions

I have UIView designed in IB, and UITableView on it. In view contoller's viewDidLoad
In my application I have a uitabbar contoller for managing the three view controllers.
In my view controller's -viewDidLoad method, I call [myTextField becomeFirstResponder]; This works like a
I have a modal view controller, and I want its navigation bar (I think
I have a table view controller with (among others) a cell that is to
I have a view controller with a scrollview with lots of text boxes, when
If I have a view controller that has an NSOperationQueue as an instance variable,
I have a view controller based app that contains several views that I display/hide
I have a main view controller that consists of 1 button that when tapped,
I have a Modal View Controller, and a Navigation View Controller embedded in a

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.