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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:34:51+00:00 2026-05-23T09:34:51+00:00

How can I load nib from a UIView in iOS 4 ? I don’t

  • 0

How can I load nib from a UIView in iOS 4 ?

I don’t have a UIViewController, since I’m adding this custom view to a parent view.

I want to initialize this custom view from a nib file. Which initializer should I use ? initWithFrame or initWithCoder ?

So far, I’ve only assigned the custom class in the interface builder. (See pic: http://cl.ly/7pmj). Is this necessary ? If so, it is still not working, why is it not enough ?

NB I’ve found this related question in StackOverflow. However, it doesn’t explain how to initialize the view itself with the nib.

I need to customize drawRect method, for this view, so I can’t just add a subview from a nib file. I need the view itself being initialized from the nib file.

thanks

  • 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-23T09:34:51+00:00Added an answer on May 23, 2026 at 9:34 am

    Use the method from the related question (NSBundle loadNibNamed) and make sure the owner in that call is an object that has an IBOutlet for the view in question.

    Hook that iboutlet up to the view in interface builder (you will need to set the class of the owner in IB to the class of the owner in your load nib call).

    The nib will load the view into that iboutlet variable.

    In .h file:

    IBOutlet UIView *myView;
    

    in .m file:

    [[NSBundle mainBundle] loadNibNamed:@"viewToLoad" owner:self options:nil];
    [someOtherView addSubView:myView];
    

    The rest is in IB.

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

Sidebar

Related Questions

I have a UIViewController that I want to load from a NIB that has
I have an issue with a View Controller which is loaded from a NIB.
I have a document-based Cocoa app. During runtime, I load an additional nib from
I'm reading a custom table cell in tableView:cellForRowAtIndexPath: from a nib file. This works
I use a grouped tableview and custom cells which I load from nib. When
I can load COM DLLs that are registered on my machine like this: Type
Apache Pig can load data from Hadoop sequence files using the PiggyBank SequenceFileLoader :
I have a web application that can load plugins through reflection. It currently uses
I have a CSV of file of data that I can load in R
How do you update this environment variable at runtime so that ctypes can load

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.