Frage

I've started learning Cocoa app development, and this simple problem is bugging me for hours, I'm sure it's something simple.

Problem:

I create a new OS X project. I drag NSScrollView on the window, then I drag a simple button within the scroll view.

When I run the program the button ( or any other content ) is hidden.

enter image description here

What am I missing here?

War es hilfreich?

Lösung

I created my own project and followed exactly the same steps you did, and I too got the same result.

My project navigator contained one warning regarding a "Misplaced View":

Misplaced View: Frame for "Clip View" will be different at run time.

Size will be (0, 0) at run time but is (181, 94) in the canvas.

Further research indicates this is an issue with the new auto-layout functions Apple is pushing:

Xcode5 defaults to using Auto-Layout. The warnings mean that some of your UI elements do not have enough constraints set, so when you manipulate the UI (for example resize the window) things may look different than you intended.

When you open MainMenu.xib in Interface Builder, a yellow arrow should appear in the component section. Click that arrow and a view appears that explains the offending elements. Each has another yellow element that brings up a context menu with suggested fixes.

I used a slightly different approach to correct the error: I used the menu option Editor > Resolve Auto Layout Issues > Add Missing Constraints in Window. The warning disappeared and the final product built exactly to the visual spec laid out in Interface Builder.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top