2014-05-07 160 views
1

我已經開始學習Cocoa應用程序開發,而這個簡單的問題讓我煩惱幾個小時,我敢肯定這很簡單。隱藏NSScrollView嵌入內容

問題:

我創建了一個新的OS X項目。我在窗口上拖動NSScrollView,然後拖動滾動視圖中的一個簡單按鈕。

當我運行程序時,按鈕(或任何其他內容)被隱藏。

enter image description here

缺少什麼我在這裏?

回答

2

我創建了我自己的項目,並遵循完全相同的步驟,我也得到了相同的結果。

我的項目導航包含在一個關於「錯位查看」警告:

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表示這是與新的自動排版功能蘋果正在推動一個問題:

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.

我用一個稍微不同的方法來糾正錯誤:我使用菜單選項Editor > Resolve Auto Layout Issues > Add Missing Constraints in Window。警告消失,最終產品完全按照Interface Builder中規定的視覺規範構建。

+0

是的,就是這樣。謝謝! – Magnuss