2014-01-13 19 views
0

我的應用程序有一個使用InspectorBar一個NSTextView。然而,它只是坐在窗口這樣的頂部:可可:如何重新定位督察酒吧

enter image description here

我希望能夠將它定位更暗下來單槓,目前是NSImageView上。 setFrame似乎沒有效果。我怎樣才能做到這一點?

編輯:我目前正在修復別人的項目實施。正如您在下面看到的,他們能夠移動檢查器欄,並且它們不使用NSToolbar。所以它一定是可能的。

enter image description here

下面是這個人怎麼實現的是:

- (void) addStyleBar 
{ 
    NSArray* subviews = [self.window.contentView superview].subviews; 
    [self.styleBar removeFromSuperview]; 

    [subviews enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) 
    { 
     if (![obj isKindOfClass: [MainView class]]) 
     { 
      self.styleBar = obj; 
     } 
    }]; 

    [self.styleBar setFrame: NSMakeRect(300.0f, 2.0f, CGRectGetWidth(self.styleBar.frame), CGRectGetHeight(self.bounds))]; 

    [self addSubview: self.styleBar]; 
} 

但是,這並不在我的計劃有任何影響。

編輯2:如果我添加一個約束,像這樣:

[[self.leftColumnVC.textView.window.contentView superview] addConstraint:[NSLayoutConstraint constraintWithItem:inspectorBarView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:formattingBarBackground attribute:NSLayoutAttributeTop multiplier:1 constant:0 ]]; 

這裏formattingBarBackground是暗灰色條第一圖像中可見的上方。如果我這樣做,我得到這個:

enter image description here

這是好事,因爲有在頂部欄中沒有預留空間,並通過窗口的子視圖遍歷我仍然可以得到NSInspectorBar的引用,所以它仍然存在,它只是不可見。它隱藏在formattingBarBackground圖像視圖後面嗎?如果是這樣,我怎麼能把它帶到前面?

回答

1

檢查員酒吧坐在窗口的工具欄下方。所以你的問題是由於你的「iTunes」UI的實現引起的。如果要在NSToolbar中將其實現爲NSToolbarItems,則Inspector Bar會自動將其置於其下方。

There is no API to alter to the location of the Inspector Bar,所以這是最好的你可以做(​​短缺實施自己的檢查員欄)。

+0

感謝您的回覆。請參閱我的編輯。 –

+0

@JamesHarpe Yikes!這是*絕對*不支持;對不起,幫不了你。 :( –

+1

我們最終選擇使用NSToolbar。謝謝! –