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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:47:42+00:00 2026-06-17T14:47:42+00:00

I am trying to create a custom view, with a nib and attendant .h/.m

  • 0

I am trying to create a custom view, with a nib and attendant .h/.m files, and then create multiple instances of that view via IB, and use them as subviews of another view.

  1. I created the .h/.m files
  2. I created the xib.
  3. For the xib, I specify the class name in IB.
  4. Add some labels to the xib (the values for which will be programmatically changed)
  5. I drag a simple view in storyboard into my container view.
  6. I set the class of the dragged view to the class i specified for the xib.

I do steps 5 and 6 multiple times, once for each view I want. Eventually I would connect these views to IBOutlets on the parent view class.

Obviously I am doing something wrong because I am not seeing my labels in the custom view. I suspect I need to associate the nib with the view directly, much like you do with collection/table view, but I haven’t found where to do this.

What is the correct way to do this? I suppose I could add views programmatically, but then how do I handle the layout for various devices (e.g. iphone 4 vs 5)?

  • 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-17T14:47:44+00:00Added an answer on June 17, 2026 at 2:47 pm

    What I outline below appears to work

    1) Create the xib and .h/.m files for your custom view.
    1a) Assuming you need IBOutlets to view elements over which you want control, give the File’s Owner the class name defined in your .h file in the identity inspector.

    2) In .h file define a property

    @property (nonatomic, retain) IBOutlet UIView *contentView;

    2a) define outlets for all the subviews in your xib, to which you want programmatic access.

    3) In the .m file synthesize the property and do

    - (void)awakeFromNib
    {
        NSLog(@"awake from nib");
        [[NSBundle mainBundle] loadNibNamed:@"yourNibName" owner:self options:nil];
        [self addSubview:self.contentView];
    }
    

    4) Drag empty views from the palette into their container in the storyboard. Change the class
    of these views to the class name defined in your .h file.

    When you run your app you should see the contents of the xib in your subviews.

    5) You can now define outlets to your custom subview instances in the .h file of the container view, and connect them as usual in the storyboard.

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

Sidebar

Related Questions

I am trying to create a custom popup view that can be called from
I'm trying to create a CGRect inside of a custom view (rectView) that will
I was trying to create custom view pages in ROR as seen in http://blog.hulihanapplications.com/browse/view/55-ruby-on-rails-multiple-model-form-generator
I've been trying to create a custom view that is to be used to
I am trying to create a custom UIView that is stored in a nib
I am trying to create a custom View that would replace a certain layout
I'm trying to create a custom table view cell that has a button on
I'm trying to create custom view that draws image downloaded from Url. The code
I'm trying to create a custom view (one that is not 100% listview, for
I'm trying to create a custom view GhostSurfaceCameraView that extends SurfaceView . Here's my

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.