我正在尝试在mac应用程序的视图中显示NSWindowController
类作为模态表
问题是默认模态来自向下滑动。
SettingWindowController *obj=[[SettingWindowController alloc] initWithWindowNibName:@"SettingWindowController"];
[NSApp beginSheet:obj.window
modalForWindow:[self.view window]
modalDelegate: self
didEndSelector: @selector(didEndSheet:returnCode:contextInfo:)
contextInfo: nil];
当我执行上面的代码时,它只是在视图外打开第二个窗口控制器。
如何通过滑动获得默认行为,即视图从上到下。
答案 0 :(得分:1)
-(IBAction)showModel:(id)sender {
obj=[[SettingWindowController alloc] initWithWindowNibName:@"SettingWindowController"]; obj.delegate=self; [NSApp beginSheet:obj.window modalForWindow:[self.view window]
modalDelegate: self didEndSelector: @selector(didEndSheet:returnCode:contextInfo:)
contextInfo: nil]; }
- (void)didEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
[obj.window orderOut:self];
}
-(void)showModelEnd
{
[NSApp endSheet:obj.window];
}
答案 1 :(得分:0)
-(IBAction)showModel:(id)sender { obj=[[SettingWindowController alloc] initWithWindowNibName:@"SettingWindowController"]; obj.delegate=self; [NSApp beginSheet:obj.window modalForWindow:[self.view window] modalDelegate: self didEndSelector: @selector(didEndSheet:returnCode:contextInfo:) contextInfo: nil]; } - (void)didEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { [obj.window orderOut:self];
}
-(void)showModelEnd
{
[NSApp endSheet:obj.window];
}