MAC中窗口的实现

1 新建一个NSWindowController的子类FileSaveWindowController
2 新建的xib文件,fileOwner设置为FileSaveWindowController类型,关联window

3 调用窗口,如下:

FileSaveWindowController  *_savePathWindow;

_savePathWindow = [[FileSaveWindowController alloc] initWintWindowNibName:@"FileSaveWindowController"];

[_savePathWindow loadWindow];


Mac中对话框显示方法有两种,一种跟windows的对话框一样,另一种为Sheet(卷帘式)对话框。

windows风格的对话框,分模态和非模态

非模态:[[dialogCtl window] makeKeyAndOrderFront:nil];

模态:[NSApp runModalForWindow:[dialogCtl window]];


sheet对话框都是模态对话框,显示方式:

NSApp beginSheet:[dialogCtl window]
       modalForWindow:[NSApp mainWindow]
        modalDelegate:nil
       didEndSelector:nil 
          contextInfo:nil];
    
[NSApp runModalForWindow:[dialogCtl window]];

如果使用sheet方式的对话框,在对话框退出时,需要在DialogController中调用如下代码:

[NSApp stopModal];
[NSApp endSheet:[self window]];
[[self window] orderOut:nil];


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值