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

The Archive Base Latest Questions

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

I have a custom UIView object with a nib that defines the view/subview layout.

  • 0

I have a custom UIView object with a nib that defines the view/subview layout. My outlets are connected, and when I init the object from initWithFrame: everything is in order.

The problem I’m having is when I’m using IB to embed the UIView into another nib; the custom UIView appears, but none of the subviews it contains appear – in fact their symbols all resolve to nil. I have a very minimal initWithCoder: and awakeFromNib: implementation (just does logging) and my understanding is that as the nib is deserialized the subviews should at least be initialized during the process?

The only conclusion I’m coming to on my own is that one of two things is happening: either my outlet references are corrupt/bad and aren’t working, or my understanding of load-from-nib process is faulty and I’m missing something.

Thanks in advance!

Edit: (Code posted for Nekto as requested… as you’ll see, it does logging and thats it, heh.)

- (id)initWithCoder:(NSCoder *)aDecoder {
    if ((self = [super initWithCoder:aDecoder])) {
        NSLog(@"ThumbnailGridView.initWithCoder frame= %f, %f", self.frame.size.width, self.frame.size.height);
    }
    return self;
}

- (void)awakeFromNib
{
    NSLog(@"ThumbnailGridView:awakeFromNib");
}

Edit 2: Nibs, controllers, subviews, etc.

Nibs: I have a single nib containing a UIView. This UIView contains a single UIScrollView, which is filled with a grid of UIViews that are defined in another nib. (Note: this part works fine, as the fill is done programmatically and works with an initWithFrame: call.) The problem here is that the UIScrollView symbol is nil after initWithCoder: and awakeFromNib: are both called, so objects are just being added to nil and nothing happens. If the scrollview symbol was not nil, I’m sure this would work.

Controllers: There are two controllers that utilize this, one is done with initWithFrame: and works perfectly, the other embeds it as a nib-based reference. (As mentioned elsewhere here, defining a UIView in IB, setting the custom class.) I stepped through the code, and that view -is- being initialized properly – only its subviews are “missing”.

Does this help give a clearer picture of the situation at all?

  • 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:19:07+00:00Added an answer on May 25, 2026 at 10:19 pm

    You may be misunderstanding how nib loading works. If you define a custom UIView and create a nib file to lay out its subviews you can’t just add a UIView to another nib file, change the class name in IB to your custom class and expect the nib loading system to figure it out. You need to modify initWithCoder of your custom UIView class to programmatically load the nib that defines its subview layout. e.g.:

    - (id)initWithCoder:(NSCoder *)aDecoder {
        if (self = [super initWithCoder:aDecoder]) {
            [[NSBundle mainBundle] loadNibNamed:@"CustomView" owner:self options:nil];
            [self addSubview:self.toplevelSubView];
        }
        return self;
    }
    

    Your custom view’s nib file needs to have the ‘File’s owner’ class set to your custom view class and you need to have an outlet in your custom class called ‘toplevelSubView’ connected to a view in your custom view nib file that is acting as a container for all the subviews. Add additional outlets to your view class and connect up the subviews to ‘File’s owner’ (your custom UIView).

    Alternatively, just create your custom view programmatically and bypass IB.

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

Sidebar

Related Questions

I have a custom UIView that acts as a layout object. If I add
I have a custom UIView that generates a set of subviews and display them
I have a custom UIView that contains an interactive drawing that is drawn in
I have a custom UIViewController, which is the only subView of UIView. The UIViewController
I currently have a simple iPhone app that loads a custom subclass of UIView.
I have a custom UIView that draws an image in the draw rect method.
I have a UIView that gets loaded with several custom NSObjects (graphShape). Each graphShape
I have an object that has an NSMutableArray of custom UIViews, a UIImage, and
Setup: I have a custom class I've created that handles data retrieved from a
i have a not custom table view view that i mean that i'm 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.