将NSTextField的文本重置为空字符串 - setText:不工作 [英] Reset NSTextField's text to empty string -- setText: doesn't work

查看:484
本文介绍了将NSTextField的文本重置为空字符串 - setText:不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 NSTextField ,我需要一个按钮来重置字段的文本。我该怎么做?我一直在尝试这个:

I have an NSTextField, and I need a button to reset the text of the field. How would I do that? I have been trying this:

[textBox setText:@""];
textbox.text = @"";

这不起作用,但我已经研究过,没有发现如何设置文本,如何获取文本。

That does not work, but I have researched, and found nothing on how to set the text, only how to get the text.

推荐答案

如果是OSX和NSTextField,则使用:

If it is OSX and NSTextField then use :

[textBox setStringValue:@""];

这篇关于将NSTextField的文本重置为空字符串 - setText:不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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