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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:25:17+00:00 2026-05-27T16:25:17+00:00

I have a simple project which consists of a simple window with one view

  • 0

I have a simple project which consists of a simple window with one view coming from a NSViewController (see https://i.stack.imgur.com/UAn6L.png )

enter image description here

The view is managed (+ linked, see screenshot) to my custom view controller object.

I dragged a ViewController Object into my MainMenu.xib, connected the view outlet and set the Controller-Class + Nib-Name.

When I launch the app my custom view won’t show up in the window (“awakeFromNib” gets called in my custom NSViewController subclass!).

See Screenshot for IB details -> https://i.stack.imgur.com/UAn6L.png

Any ideas what I’m missing ?

  • 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-27T16:25:17+00:00Added an answer on May 27, 2026 at 4:25 pm

    I’m presuming you have a separate Nib named CustomImageView that is not pictured (the one created automatically by Xcode). In that case you would add your controls and drawing code to the view in that separate Nib. To actually add that view controller’s view to the window, you’ll have to do it programmatically by making an IBOutlet connection from your AppDelegate to the view controller, and adding the following code when you want to add the view: (typically in applicationDidFinishLaunching:)

    [viewController.view setAutoresizingMask:(NSViewWidthSizable|NSViewHeightSizable)];
    [viewController.view setFrame:NSInsetRect([window.contentView bounds], 20, 20)];
    [window.contentView addSubview:viewController.view];
    

    That will place it inset and centered like you have in the screenshot. The problem is that by creating the view connection in your MainMenu Nib you are overriding the connection in the separate, CustomImageView Nib. You can delete the Custom View object in your window… you’ll have to add you custom view programmatically. It would be nice if it worked that way, but it doesn’t.

    EDIT:

    It’s because of the order that the nibs are unarchived. First CustomImageView is instantiated and all its connections are made. At this point the view property is correctly set. Then MainMenu hooks up the view property again, overriding the view property in the separate Nib. Now the view property is incorrectly set. That’s normal behavior. If you’re using separate nib you have to leave that unconnected and add the view controller’s view in code.

    An alternative would be to not use a separate Nib. Just delete it from your project, set up your view-in-window and leave your connection as-is. Now you can have a separate view controller managing it, without having to add any code. You really only want a separate Nib if the view is very complex, or if you want to load it lazily as needed, like if the user could select different views for the main window.

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

Sidebar

Related Questions

I have simple test project which creates a frame and adds one JTextPane to
We have simple project which takes a number of messages from a number of
i have created a simple public ref class in the vc++ project, which is
We have a simple project where we read data from a socket and we
I have a simple HTML form which consists of radio buttons where user has
I have a simple project to present a modal view controller and transfer back
We have a simple project that uses JsonValueProviderFactory which we have working on a
I have been working on a project which partially consists of a HttpModule. I
I have built a simple project which use Winsock Tool. When I receive any
I have a simple project in which I'm attempting to do some rewriting of

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.