2011-10-19 23 views
1

MAAttachedWindowのビューをウィンドウでスワップするにはどうすればよいですか?MAAttachedWindowのビューを交換する方法

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

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

AnotherViewControllerのビューではどうやって入れ替えることができますか?

答えて

1

良い夜の睡眠の後、これを理解するのに5分かかりました!

単にスワップビュー方式で次に
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]; 

-(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]; 
} 
関連する問題