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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:54:33+00:00 2026-06-08T02:54:33+00:00

I have a xib with a root view that is a UIView subclass. How

  • 0

I have a xib with a root view that is a UIView subclass. How should this view get references to the child views I declared in Interface Builder?

Obviously a ViewController can be wired up with outlets, but what about a UIView?

  • 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-08T02:54:35+00:00Added an answer on June 8, 2026 at 2:54 am

    Outlets are properties of UIViewController objects which (almost always) refer to instances of UIView objects (or subclasses of UIView).

    A UIViewController has a single UIView which, when the UIViewController is loaded with initWithNibNamed:, is the contents of the XIB file. You can set up outlets in the UIViewController and then tie them to the various subviews in your XIB by dragging to the “File’s Owner” item in the list, or by dragging to the code in Xcode’s assistant editor.

    If you want to use only code, there are several options. One way, is to directly access a view based on its tag property. For example:

    [myView viewWithTag:42];
    

    Another approach to consider is that a UIView has a property called subviews, which is an array of sub views. You can iterate through them and access the views as necessary. To differentiate between them, you can do several things, depending on the situation. You can set tags on the views, and just use those.

    NSArray *subviews = myView.subviews;
    
    for(UIView *view in subviews){
      if(tag == 42){
        // Do something with that view
      }
    }
    

    Alternatively, if you’re looking for a specific kind of view, say, a UISwitch, something like this might work in simple cases:

    for(id view in subviews){
      if([view isKindOfClass:NSClassFromString(@"UISwitch")]){
        // Do something with that view, since it's a switch 
    
      }
    }
    

    If you’re using tags, you can set them in code, or use Interface Builder.

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

Sidebar

Related Questions

I have a XIB set up like in this screenshot: alt text http://emberapp.com/jxpx777/images/interface-builder/sizes/m.png File's
I have two views within one .xib (one view for landscape, another for portrait).
There's something fundamental that I'm not understanding about presenting views that get their interface
I have a XIB file with my controls in it, loaded in the Interface
I have created a custom view with a XIB file and are loading the
I have created a custom UIView (without .xib) for a finger paint application. Paint
I have one .xib file with an App Delegate. In this App Delegate, I
I have MainWindow.xib in the application. In the Interface Builder, I rotate the main
I have an xib with a single UIView containing a bunch of images and
In my app I have a xib that has several viewcontrollers and xibs (with

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.