【发布时间】:2012-10-10 21:36:44
【问题描述】:
我对 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];
}
当我运行应用程序时,我会得到如下信息:
我被困住了,我不知道这有什么问题。我无法获得工作表,甚至无法关闭应用程序。我参考了网上的一些例子。
【问题讨论】:
标签: macos window cocoa-sheet