1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Yet another programming question: NSView in different places [workaround failed]

Discussion in 'Mac Programming' started by Eraserhead, Feb 17, 2007.

  1. macrumors G4

    Eraserhead

    #1
    Sorry for asking loads of questions recently :eek:, I really appreciate the help.

    I have an issue when I have an NSView that I want to display in different places, what happens is that the second time you view the subview it fails to appear. I have created an example application that shows the problem. If you switch to the second tab view at the top (which also has a subview with the same view in it.) and then switch back to the first tab the subview has disappeared.

    I'd like it still to appear in the first sub-tabview when switching back, what am I doing wrong so it doesn't appear, is there some documentation I need to read? No errors appear on the console.
     

    Attached Files:

  2. macrumors G4

    Eraserhead

    #2
    I have found a workaround, basically rather than just doing whats below to set the view to the new object,
    Code:
    [[tabView2 selectedTabViewItem] setView:theView];
    
    I create a brand new tab view item, delete the old one and set the view to the brand new tab view item using this code:

    Code:
    NSTabViewItem *oldView=[tabView2 selectedTabViewItem];
    NSTabViewItem *newView=[[NSTabViewItem alloc] init];
    [newView setLabel:[oldView label]];
    [tabView2 insertTabViewItem:newView atIndex:0];
    [[tabView2 selectedTabViewItem] setView:theView];
    [tabView2 removeTabViewItem:oldView];
    
     
  3. macrumors G4

    Eraserhead

    #3
    OK, the new code isn't working, I have expanded the test case and it works when the view is a subview of the first set of tabs but not if it's a view of a subtab (even though the same code is used for both), I'm submitting a bug-report to Apple, unless I'm doing something stupid.
     

Share This Page