NSPanel removed in Xcode 8? - macos

In the past I can find Panel available in Interface Builder's Library, but in Xcode 8, I searched the whole library in storyboard editor, no Panel available. Has Apple just removed NSPanel or I got something wrong?

Assuming you want to add a second window (as a panel) to your storyboard, add a new window controller. Then select its window and change its class to NSPanel. In the attributes inspector you will find that your panel can then be changed to regular, utility or HUD.
For Cocoa apps, I find that Nibs/Xibs are sometimes easier to work with than storyboards.

Related

Connecting a Label/Button from StoryBoard to ContentView in Xcode 13

Options Window
How can I connect a label, button, or other element from my Storyboard to my coding file in Xcode 13? When I first loaded Xcode, there was no storyboard file added to my project. I had to add one myself. Then, when I created labels and buttons on the Storyboard, it wouldn't allow me to connect to the coding file the way I used to (clicking Ctrl and dragging the label/button to the code). I feel like I'm missing something simple but I can't find any solutions online. Thanks in advance.
You have selected a Multiplatform template. This is only supported by SwiftUI.
Select a single platform template (iOS, macOS etc)

How to convert manual view controller to storyboard as a launch screen

New iOS requirements need Apps for iPhone or iPad must be built with the iOS 13 SDK or later and use an Xcode storyboard to provide the app’s launch screen.
But my project is very old and has never used Storyboards. All UI elements are created dynamically using ViewControllers.
I managed to create a storyboard file and set it as a launcher but it has no scenes and I do not know how to proceed. I would like to:
Create a scene where I place only the original launch image inside (hoping that apple still accepts this branding)
If it is possible to just connect my main ViewController with the scene (if that works with dynamical ViewControllers)
If nothing helps than I would need to create a simple scene which has just a bottom bar like my ViewController
I had this exact issue, here's what I did:
Create LaunchScreen.storyboard and set to use it as launch screen
Using the + button in the top-right (this was not an obvious step), add a View Controller into the storyboard
Untick "Use Safe Area Layout Guides" on the right panel if you're getting that error
Tick "Is Initial View Controller"
Then clean and run, for me it just worked. I did have trouble seeing it update though, as discussed here: Launch Screen storyboard not displaying image

OSX Multiple toolbars in NSTabViewController

I have a structure which is represented in the picture below (sorry but apparently in OS Sierra Xcode does not support anymore zooming in the storyboard -.- )
Window > TabController > View Controllers
Basically what I wanted to do is to have multiple toolbars, each one for a different ViewControllers. If I were on iOS I could have set a UINavigationController as target of the TabViewController and then do whatever I wanted with the related navigation bar, but here in OSX I cannot link the TabViewController to a WindowController (which handles the toolbar), hence having a window controller per view controller.
Is there any simple workaround for that?
Or the only solution is to empty-refill the toolbar with the correct buttons every time a Tab is selected?

Cocos2d-x OS X application menus

I have a cocos2d-x application that I have been mostly debugging on iOS. Now I am working on the OS X side of things.
As expected, everything works pretty much the same, except that I have some gesture commands in my iOS app that do not translate to OS X.
I would like to create menu items (OS X level) and associated shortcuts to accomplish some of the gesture interactions (at least as one option).
Creating a MainMenu.xib and linking it in the project settings doesn't seem to be the whole story. The menus are still the generic "AppName" and Window menus, and not the ones I created in the xib file.
I believe I need to wire it up to the AppDelegate somehow, but I'm not sure how, and I haven't had any success finding documentation to that effect, at least in relation to how it interplays with Cocos2d-x.
Essentially you just need to create the menu in an Objective-C++ class that you call from AppDelegate.cpp or wherever. The extension will be .mm in order to invoke the objective-c compiler/runtime. You can then create the NSMenu and add items or replace an entire menu set[ServiceMenu/WindowMenu/MainMenu]
NSMenu reference: https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSMenu_Class/index.html)
I found the only interesting part was receiving an action from the menu where I believe you need to then also create an objective-c class as the receiver (target).
You should be able to load the .xib file in as a entirely new menu to replace the one GLFW3 creates, but I haven't looked into that yet.
Update: Here's an example project.
https://github.com/stevetranby/TestNSMenuCocos2Dx
Update: Added example to project for loading the menu with .xib

How do I get Autosize feature to show up for objects in Interface Builder?

I'm brand new to Mac OS X development and to Xcode and the Cocoa framework. I've been working through the "Your First Mac App" tutorial on the Apple's developer website and have run into a snag. I've made it most of the way through but am hung up in the section where it shows you how to use Autosizing on the gui objects. When I click on the slider(or any of the objects) and then select the size inspector I do not have any of the autosize items in the inspector window like it shows in the tutorial. How do I get those options to show up?
This is a new feature in XCode 4 called Constraints. It's just an other way to define how your user interface should be resized when the window (or parent view) is resized. If you want to use the Autoresizing Mask settings from the tutorial, go to the File Inspector (first tab on the right) and uncheck Use Auto Layout.

Resources