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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:29:30+00:00 2026-06-09T04:29:30+00:00

I have a UIViewController with an UIScrollView in it. Then I created a new

  • 0

I have a UIViewController with an UIScrollView in it.

Then I created a new UIView subclass with some properties that I want to programmatically add in this UIScrollView until my data ends.

Something that should look like this picture:
embed uiview

I have read other topics that does that by creating a view and setting its class to the custom view subclass, but I want to do it programmatically and its not working.

how would I do that?

  • 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-09T04:29:31+00:00Added an answer on June 9, 2026 at 4:29 am

    From your image it looks like you’re looking to load views from a nib and add them as subviews of your UIScrollView. To do this have a look at the UINib documentation.

    You want to create your nib and set it’s main view to be an instance of your UIView subclass then load the nib in viewDidLoad of your viewController, and add the nib’s views as subivews of your scrollview (which I’m assuming is a subview of your viewController’s view).

    You can instantiate a nib with instantiateWithOwner:options:.

    This method unarchives each object, initializes it, sets its
    properties to their configured values, and reestablishes any
    connections to other objects

    To get the array of views from a nib you do something similar to:

    UINib *myNib = [UINib nibWithNibName:@"myNib" bundle:[NSBundle mainBundle]];
    NSArray *viewsFromNib = [myNib instantiateWithOwner:nil options:nil];
    

    I’ll assume we’re inside a UIViewController and we’re somewhere in (or after) viewDidLoad. You would then use the array from above and add the views as subviews of your scrollview. You may need to set the frames of these views to place them properly, but that should be trivial.

    UIView *aView = [viewsFromNib objectAtIndex:0];
    [self.scrollView addSubview:aView];
    

    I hope that sets you in the right direction.

    Edit:

    If you want more information you may need to read deeper into how nibs work to manage your expectation. Linked with the UINib documentation is the ‘Resource Programming Guide’ in particular the nib section

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

Sidebar

Related Questions

So I have a UIViewController subclass called MyTabBarViewController that has a UIScrollView. Inside of
At the moment I have a UIViewController subclass with a UIScrollView and a UIView
I have a zooming UIScrollView that contains a UIView which contains some custom UIViews
I have a UIScrollView that I need to subclass and within the subclass I
I have a UIViewController, on top I put an UIImageView, then a UIScrollView. I
I have a UIViewController subclass which has the view property set to a UIScrollView
Following Scenario: I have a = UIViewController A that contains a UIScrollView I have
I have a simple ViewController that looks like this: @interface MyViewController : UIViewController<UIScrollViewDelegate> {
I have a UIViewController that implements a UIScrollView with the UIScrollViewDelegate. Attached to it
I have a custom UIViewController subclass controlling a UISCrollView containing an UIImageView, set up

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.