2011-10-19 3 views
1

Comment est-ce que je peux échanger l'affichage de MAAttachedWindow avec la fenêtre visible?Comment changer la vue de MAAttachedWindow

defaultViewController = [DefaultViewController alloc] initWithNibName:@"DefaultView" bundle:nil]; 

attachedWindow = [[MAAttachedWindow alloc] initWithView:[defaultViewController view] 
               attachedToPoint:point 
                 inWindow:nil 
                 onSide:MAPositionBottom 
                atDistance:25.0]; 

Comment est-ce que je permuterais dans la vue de AnotherViewController?

Répondre

1

Après une bonne nuit de sommeil, il a fallu 5 minutes pour comprendre cela!

NSViewController *vc = [[NSViewController alloc] initWithNibName:@"MainView" 
                   bundle:nil]; 
view = vc.view; 
[vc release]; 

// Setup firstViewController here, addSubview and set current = firstViewController.view 

attachedWindow = [[MAAttachedWindow alloc] initWithView:view 
             attachedToPoint:pt 
               inWindow:nil 
               onSide:MAPositionBottom 
              atDistance:5.0]; 

Ensuite, dans ma méthode vue d'échange, simplement:

-(void)swapView 
{ 
    SecondViewController *secondViewController = [[SecondViewController alloc] initWithNibName:@"SecondView" bundle:nil]; 

    // Resize our host view 
    [view setFrameSize:secondViewController.view.frame.size]; 

    // Replace the current view 
    [view replaceSubview:current with:secondViewController.view]; 

    // Resize our attachedWindow 
    [attachedWindow setFrame:secondViewController.view.frame display:YES]; 

    [secondViewController release]; 
    [current release]; 
} 
Questions connexes