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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:33:10+00:00 2026-06-09T17:33:10+00:00

My goal is, to have a subclassed UIView (lets call it infoView ) designed

  • 0

My goal is, to have a subclassed UIView (lets call it infoView) designed in his own XIB so that I can present it in many UIViewController‘s.

The Problem:
So far, when I was adding UIView‘s to a UIViewController I always had to make an UIViewController the file’s owner of the UIView‘s .xib file to load the view with something like:

...
//this is inside the calling UIViewController's method
// InfoView *infoView is ivar and a subclass of UIView
infoView = nil; 
NSArray *bundle = [[NSBundle mainBundle] loadNibNamed:@"InfoView"
                                                owner:self options:nil];

for (id object in bundle) {
    if ([object isKindOfClass:[InfoView class]])
        infoView = (InfoView *)object;
}   

[[self view] addSubview:infoView]; 
...

But I want to use the same UIView in many different UIViewController‘s, so I actually don’t want a file’s owner except maybe the class itself. In ThomasM’s question he was setting the UIView itself to be the file’s owner but without success.

In the answers there I found a solution to set the file’s owner to nil. To do so I had to add all calling UIViewController objects from the Interface Builder object library to the InfoView.xib file and connect them with their infoView outlets.

But this doesn’t feel right. So here I would like to collect solutions to
encapsulate a UIView together with his xib-file to use it in many different view controllers. How do you guys handle that?

Thx for any help.

EDIT:

The infoView is something like an overlay which appears when the user presses a button on one of the view controllers. It’s NOT the View controllers “main” view. It gives detailed informations about the view of his superviews view controller and will disappear afterwards. I only fill the infoView with different contents threw out all the calling view controllers.

  • 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-09T17:33:12+00:00Added an answer on June 9, 2026 at 5:33 pm

    Like Hollance answer was pointing out I am using UINib.

    To use it, leave the .xib files owner nil and place all customization of the infoView inside the initWithCoder: method of your InfoView class implementation. This will get called if you obtain the InfoView.xib like:

    // here InfoView is the name of the .xib file
    UINib *infoNib = [UINib nibWithNibName:@"InfoView" bundle:nil];
    
    NSArray *topLevelObjects = [infoNib instantiateWithOwner:self options:nil];
    
    QInfoView *infoView = [topLevelObjects objectAtIndex:0];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an abstract Singleton class. My goal is that any subclasses just have
I have an UIViewController which contains a UITableView (subclassed) and another UIView (subclassed). They
Goal - have a section of my sidebar that is conditional depending on what
Final goal: Have a few java objects sharing the same base class persisted into
goal: I have the string 1234432144 I want to only replace the first 2
Let me first describe my goal: I have created an object with 3 properties:
The goal is to have the member variable _AddValue point to the CreateFirstValue function
My goal is to have an Android phone (Samsung Galaxy Nexus) communicate with a
My goal is to have the url routing as following: http://www.abc.com/this-is-peter-page http://www.abc.com/this-is-john-page What is
My goal is to have a jQuery datepicker pop up when the user clicks

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.