我对OSX开发非常陌生。考虑这是我的第一个应用程序。我想在主窗口上单击按钮时显示工作表。我使用笔尖工作表在OSX上无法正常显示
以下是我的.h文件中
#import <Foundation/Foundation.h>
#import "WebKit/Webkit.h"
@interface MainViewObject : NSObject
- (IBAction)accountButtonPressed:(id)sender;
- (IBAction)cancelSheetButtonPressed:(id)sender;
.m文件代码如下
#import "MainViewObject.h"
@implementation MainViewObject
- (IBAction)accountButtonPressed:(id)sender {
[NSApp beginSheet:self.accountSheet
modalForWindow:[mainWindowView window]
modalDelegate:nil
didEndSelector:nil
contextInfo:nil];
[NSApp runModalForWindow:self.accountSheet];
[NSApp endSheet:self.accountSheet];
[self.accountSheet orderOut:self];
}
- (IBAction)cancelSheetButtonPressed:(id)sender {
// Return to normal event handling
[NSApp endSheet:self.accountSheet];
// Hide the sheet
[self.accountSheet orderOut:sender];
}
当我运行应用程序,我得到这样的:
我被卡住了,我不知道这个错误。我无法获取表格,甚至无法关闭应用程序。我在网上提到了一些例子。
我用你最后给出的代码。当我运行应用程序时,我发现在点击按钮获取表单之前,两个窗口都显示出来。这里是同一个http://i.imgur.com/XWNSk.png – Nik
关于如何最初隐藏工作表窗口的任何想法的快照,因为我发现如果关闭默认打开的工作表(如以前的注释链接所示)并按下它的按钮工作正常 – Nik
@Raj:更新的答案 – NSGod