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

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.

Related

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?

NSPanel removed in Xcode 8?

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.

Swift - Problems with layout

I have a Universal application in Swift 2.0 developed in XCode 7.
On the storyboard simulated metrics, I have the 'size' set to 'iPhone 4.7-inch'.
When I run the application on my device (iPhone 5s), none of the labels are aligned and the toolbar is out of view. -This is also the case when I run using the iPad device in XCodes simulator.
Image of what the view controller contains ...
From the snippet above, when I run this VC on my iPhone there is no margin on the right side, and the toolbar is cropped off.
Can anyone advise how I can make a universal application show all the content in the VC, on all devices. Or how I would simply show the toolbar ...
That's what auto layout (constraints) is for.
On the storyboard simulated metrics, I have the 'size' set to 'iPhone 4.7-inch'.
That's irrelevant, and indeed misleading, since in means that only on the iPhone 4.7-inch will your app look like the storyboard design — unless you use auto layout.
iPhones come in many screen sizes. Basically, you have no way of knowing, as you design, what the screen size will actually be! Auto layout is the solution. Auto layout allows your interface elements to adjust automatically as the app launches on a particular size screen. iPads can serve as an extension of this — i.e., just an even larger size screen — or you can even use conditional constraints to make the interface quite different on the iPad from the iPhone, if desired - all designed in a single storyboard.
Maybe you are using auto layout and auto constraint. You could deactivate this in opening the storyboard, open up right panel , go to "show the file inspector" section and under Interface Builder Document uncheck auto layout and auto constraint
Image here
Select your item view, go into "Show the size inspector" and there you can set your autoresizing for all devices

Xcode osx scroll view

I am going round in circles trying to get a custom view to scroll correctly.
To simplify this.
I create a new OSX cocoa application.
Go to the xib file, select the window. drag a custom view, then drag a few buttons into it.
Run the program, you have a button in the screen.
Now go back the custom view, select editor -> embed in -> Scroll view
Everything looks fine, and suggests you will have two buttons with scroll bars in the custom view.
Run the program, the custom view shows with scroll bars, but the button do not show.
What am I doing wrong?
Following your instructions I have created and changed the project. No problem.
Run in IB your "app", CMD R. The user interface itself can be checked in this way.
If problem remains
Check the layer position->Click on the custom View
Is it possible to Layout->Send to back? If yes, then your button-scrollview is not embedded.
Unembed the button, view and repeat the process, by checking in IB if now the interface shows appears correctly.

Resources