如何在Objective-c中编写“确定"按钮动作? [英] How to write the ok button action in Objective-c?

查看:166
本文介绍了如何在Objective-c中编写“确定"按钮动作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是的问题的新手.我创建了一个对话框,并在对话框上单击确定按钮.现在,我正在对对话框进行一些操作.之后,我要单击确定"按钮以关闭对话框.为此,我正在做

I am new in xcode. I have created a dialog and ok button on the dialog. Now, I am doing some operation on dialog. After that I want to click on ok button to close the dialog box. for this I am doing like

在.h文件中

@interface viewcontroller:NSViewController

@property (weak) IBOutlet NSButton *OkBtn;

@end

在.m文件中

我不知道如何在.m文件中编写ok按钮的代码.我只想单击OK按钮时,只需关闭对话框即可.

"I don't know how to write the code for ok button in .m file. I just want to when click on OK button , just close the dialog.

推荐答案

代替创建IBOutlet,您必须使IBAction直接获得点击事件

Instead of create IBOutlet, you have to make IBAction to directly get click event

查看此图片...

check out this image...

这是.m文件,我直接在其中创建IBAction

This Is .m file where i create IBAction directly

,如果您希望通过编程方式提供点击事件,请按照@Nicolas Buquet的回答

and if you want to give click event programatically then follow @Nicolas Buquet answer

这篇关于如何在Objective-c中编写“确定"按钮动作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆