2013-05-16 177 views
1

enter image description here隱藏顯示/隱藏按鈕(圖基於大綱視圖)

如何隱藏顯示/隱藏按鈕(編輯爲擴大在這裏)。即使我將它設置爲空字符串,數據單元的邊框也會縮小,如圖所示。以前我使用的方法- (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item,它隱藏顯示/隱藏字符串,並完美工作。但問題是outlineview只允許擴展而不是崩潰。我想通過單擊相應的父節點一次只擴展一個父節點。

+0

固定:此代碼幫助我(https://code.google.com/p/sequel-pro/source/browse/trunk/Source/SPFavoritesOutlineView.m?spec=svn4025&r=4025) – user23790

回答

1

終於解決了吧,this code幫了我。

- (NSRect)frameOfOutlineCellAtRow:(NSInteger)rowIndex 
{ 
    NSRect superFrame = [super frameOfOutlineCellAtRow:rowIndex]; 

    // Return NSZeroRect if the row is a group row 
    if ([[self delegate] respondsToSelector:@selector(outlineView:isGroupItem:)]) { 
     if ([[self delegate] outlineView:self isGroupItem:[self itemAtRow:rowIndex]]) { 
      return NSZeroRect; 
     } 
    } 


    return superFrame; 
} 
+2

我爲您使用其他委託方法提供了更好的解決方案。否則,您的解決方案可能會在任何時候中斷,例如,如果剪切停止爲您隱藏單元格。 – Dalzhim

7

使用從NSOutlineViewDelegate方法此方法:

  • (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(ID)項;