3

我对mac应用程序很陌生。以前我只为 iPhone 应用程序工作过,现在我开始学习 mac 应用程序。我创建了一个简单的应用程序,对于每个应用程序,我们在屏幕顶部都有默认工具栏。因此,在单击新建时,我想停留在当前窗口上并切换到不同的视图,其中我有一个后退按钮,单击时我想移回上一个视图。与 iphone 中的“ PushviewController ”和“ Popviewcontroller ”相同,请以任何方式建议我。我已尝试使用以下代码,但它们无法按我的需要正常工作。

-(IBAction)newDocument:(id)sender
{
    NSLog(@"<><><>Test");

    NewWindow *newWindow = [[[NewWindow alloc] initWithWindowNibName:@"NewWindow"] autorelease];
    NSView *view = [[newWindow window] contentView];
    NSLog(@"%@",view);
    [[self window] setContentView:view];
    //[[newWindow window] becomeKeyWindow];
    //[NSApp beginSheet:[newWindow window] modalForWindow:[self window] modalDelegate:self didEndSelector:nil contextInfo:nil];

}

- (IBAction)goBack:(NSButton *)sender
{
    [[self window] resignKeyWindow];
}
4

0 回答 0