7

Writing app in XCode for OSX using OSX 10.8 SDK. All of my Windows work fine, until I use Interface Building to get rid of the title bar in the nib (I uncheck the Title Bar param on the Attributes Inspector of the window element). The windows still show, but all the subviews are disabled. I can no longer input text and process bars are all greyed out.

Does anyone know why this is happening? and how to have a Window without a title bar, but with all subviews enabled?

Here is what my view looks like with a title bar: enter image description here

And here's what it looks like without: enter image description here

As you can see, everything is disabled.


Update

Someone asked about code to display windows. For this example I didn't use any code. For the two screens above here are the steps I followed:

  1. Created a new cocoa application using XCode. (Automatically creates a xib).
  2. Dragged out two controls (Text field and progress bar) onto the existing window.
  3. Ran, and took a screen shot
  4. Closed and checked off the Title Bar attribute for the window.
  5. Restarted the app. Took the second screen shot.
4

1 に答える 1

15

このリンクには、この質問に対する回答があります。

Xcode 4、Cocoa タイトル バーをインターフェイス ビルダーから削除すると、textView の編集が無効になる

NSWindow のドキュメントを読むと、タイトル バーがない場合、メソッド canBecomeKeyWindow と canBecomeMainWindow が NO を返すことがわかります。NSWindow をサブクラス化し、これらのメソッドをオーバーライドすると、キー ウィンドウになることができます。

これらのウィンドウをサブクラス化する方法に関するサンプル コードは、Apple のドキュメント Web サイト、またはドキュメントがインストールされている場合は xcode にあります。

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html#//apple_ref/occ/instm/NSWindow/canBecomeKeyWindow

上記のリンクで canBecomeKeyWindow を検索すると、プロセスの説明に役立つサンプル コードが含まれています。

于 2013-07-24T17:53:52.390 に答える