我現在第一次開發mac應用程序。所以這是我的問題。在第一次啓動時,應用程序在主菜單xib文件的自定義視圖中顯示登錄表單,登錄表單從另一個NSViewController
文件加載。問題是當我在主菜單中加載的登錄表單中點擊按鈕時,它不會響應點擊事件。我試過用performselector
方法,加Action
,也用IBAction
,都沒有工作。NSButton沒有迴應
這裏的appdelegate.m的代碼
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
NSViewController *loginformcontroller = [[LoginViewController alloc]initWithNibName:@"LoginViewController" bundle:nil];
[window setContentView:loginformcontroller.view];
}
,並在LoginViewController.m
@implementation LoginViewController @synthesize usernametxt,passwordtxt,loginbtn;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Initialization code here.
[loginbtn setAction:@selector(checkalogin)];
}
return self;
}
-(void)checkalogin{
NSLog(@"masuk");
}
有什麼建議嗎?
仍然無法正常工作。當我點擊它時沒有按鈕響應。 – Ben