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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:27:31+00:00 2026-06-11T08:27:31+00:00

i am developing an iOS application. I have a controller : iPhonePopUpController, in this

  • 0

i am developing an iOS application. I have a controller : iPhonePopUpController, in this controller i have a xib like this image :enter image description here

My question is, can i add an other xib to this Controller and loaded it when i need it or should i create a second controller to load my second xib ? enter image description here

  • 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-11T08:27:32+00:00Added an answer on June 11, 2026 at 8:27 am

    You can load anything from a XIB using:

    [[NSBundle mainBundle] loadNibNamed:@"YourOtherXIB.xib" owner:someObjectThatWillTakeThePlaceOfFilesOwner options:0]
    

    This line unarchive the XIB named YourOtherXIB.xib by creating the instances of the objects you have in your XIB, and then connect all the outlets and actions you defined in the XIB, and return the list of top-level objects.


    When you create a XIB whose File’s Owner is an UIViewController, typically you then initialize your UIViewController using code like this:

    UIViewController* vc = [[[UIViewController alloc] initWithNibName:nibName bundle:bundle] autorelease];
    

    What this code basically do internally is that it stores the nibName and bundle you provide in some internal property, and when it needs to load its view (especially the first time it needs to display it onscreen), it loads the view from the XIB using something like the line quoted above:

    [bundle loadNibNamed:nibName owner:self options:0];
    

    As you connected the view in your XIB to the view IBOutlet of the File's Owner‘s (which in that case is the self passed as an argument, namely the UIViewController itself), then the view property of your UIViewController will be populated with the view that has just been unarchived from the XIB. And that’s how UIViewController loads its view from a XIB file.

    But of course you can do the same for your own classes and do not need your File’s Owner to be an UIViewController. Simply make your File’s Owner be whatever class fits your need, expose a custom IBOutlet from this class and connect it to your objects in your XIB.

    • For example you can have a MyCustomClass class that declares an IBOutlet UIView* myOtherView;. Define the class of your File's Owner in your XIB to be of the class MyCustomClass, then bind the myOtherView outlet to the view to load from your XIB. Then in the code, create an instance of MyCustomClass and use the above loadNibNamed:owner:options: method by passing this MyCustomClass instance as the owner parameter
    • Or you can reuse your UIViewController that loaded your primary XIB to load your other view from your secondary XIB too: simply add an IBOutlet UIView* otherView in your UIViewController subclass. In your first XIB, you will connect the view IBOutlet to your primary view but keep the otherView IBOutlet unconnected. In your second XIB, you will connect the otherView IBOutlet to your other view but keep view IBOutlet unconnected. When loading your UIViewController with the first XIB, the view property will be set to the view loaded from your XIB. Then if you want to lazy-load the otherView from the other XIB at a later time, simply call loadNibNamed:owner:options with OtherXIB.xib as the nib name and self as the owner. The OtherXIB will be unarchived and otherView property will be filled with that loaded view.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an iOS 4 application. I have this ViewController: @interface BlogViewController : UIViewController
I'm developing an iOS 4 application. This question is related to UIImageView, setClipsToBounds and
I'm developing an iOS 4 application. I have a main view that contains another
I am developing an application for ios 5.1. I have now set up push
I'm developing an iOS 4.0 application. I want to add a custom UIView over
When developing on BlackBerry or iOS, you can deploy your application just by dropping
I'm developing an enterprise-like application that fetches data from a remote server. I have
I'm developing an iOS 4 application. I have a ViewController that contains another class.
I developing a Google Maps application for iOS. I have a problem. I sent
I'm developing an iOS 4 application with latest SDK and XCode 4.2. I have

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.