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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:08:21+00:00 2026-06-11T07:08:21+00:00

I have an NSView inside my project’s window as seen in the picture below:

  • 0

I have an NSView inside my project’s window as seen in the picture below:

How do I add NSImageViews to the subview of this ‘Custom View’ so its displayed in there rather than directly in the main window of the application?

  • 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-11T07:08:23+00:00Added an answer on June 11, 2026 at 7:08 am

    Programmatically, you would access the view to which you want to add subviews, then call the -addSubView: method on it. You can access it either as an IBOutlet hooked in to interface builder, or access it by Identifier (set the Identifier string in the “identity” section in the interface builder inspector). Iterate through the subviews of the windowcontroller’s view (your custom view would be one) and test the string value of “identifier”

    Here’s a simplified code snippet from a recent project for programmatically adding an extra “properties” box into a view that already has a box defined in the xib. I’m adding a new box view (propertiesBoxView) into an existing NSView (referenced by the IBOutlet-ed _detailsView) and positioning it relative to another sibling box (with its identifier set to “UI_DETAILSBOX”). An NSImageView should behave the same way as a box view:

    _propsViewController = [[MySpecialViewController alloc] initWithThings:...];
    /* snip */
    
    NSView *propertiesBoxView = [_propsViewController view];
    NSView *detailsBox = nil;
    // find the details box
    for (NSView *sibling in [_detailsView subviews]) {
      if ([[sibling identifier] isEqualToString:@"UI_DETAILSBOX"]) {
        detailsBox = sibling;
        break;
      }
    }
    if (detailsBox == nil) {
      return;
    }
    
    [_detailsView addSubview:propertiesBoxView];
    NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings(propertiesBoxView, detailsBox);
    NSArray *verticalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:[detailsBox]-9-[propertiesBoxView]-(>=9)-|"
                                                                 options:0
                                                                 metrics:nil
                                                                   views:viewsDictionary];
    NSArray *horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-9-[propertiesBoxView]-(>=9)-|"
                                                                 options:0
                                                                 metrics:nil
                                                                   views:viewsDictionary];
    [_detailsView addConstraints:verticalConstraints];
    [_detailsView addConstraints:horizontalConstraints];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a window with an subclass of NSView in it. Inside the view,
I have a custom NSView which contains a subview—for the purposes of solving this
I have a window with a main view of type NSView and a subview
I have a window which has a custom NSView and has a bottom bar
I have this code which draws a Window and NSView, and have set up
I have a custom NSView (it's one of many and they all live inside
I have this in a custom class on my NSView and when I press
I have a NSView with a NSTableView inside of it. If the view looks
I have a custom NSView that lives inside of a NSScrollView that is in
I have question about NSView: Imagine a Custom View where the mouseDown, mouseDrag and

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.