只需在 Cocoa 中制作一个标签说“Hello World”(Mac 编程)

发布于 2024-09-04 11:30:17 字数 214 浏览 0 评论 0原文

我是 Mac 上可可编程的新手,所以这个问题可能很简单。我有一个窗口,在那个窗口上有一个标签。

我希望能够从我的程序中更新此标签的当前状态或正在发生的事情(例如,读取文件、解析等)。我的问题是我不知道如何访问标签并更改其文本属性。我尝试了“MyWindowName”。希望我能够从窗口引用标签。我什至不知道标签的名称是什么,甚至不知道它是否有名称。

如何在我的程序中引用此标签来更改它?

I'm a total newbie to programming in cocoa for the mac so this question is probably easy. I have a window, and on that window I have a Label.

I want to be able to update this label from my program with the current status or what's going on (eg. reading in file, parsing, etc.). My problem is that I don't know how to access the label and change it's text property. I tried "MyWindowName." hoping I would be able to reference the label from the Window. I don't even know what the labels name is, or even if it has a name.

How do I reference this label in my program to change it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

妖妓 2024-09-11 11:30:17

您可能需要转到此处并浏览一些教程:http://www.cocoadevcentral.com/

快速总结是,与其他技术不同,您不直接访问控件(或不应访问它们)。相反,您可以在控制器中创建插座,然后以图形方式连接到控件,它们会自动更新。这些教程将为您指明方向。

You probably need to go here and walk through some tutorials: http://www.cocoadevcentral.com/

A quick summary is that unlike other technologies, you don't access the controls directly (or shouldn't access them). Instead, you create outlets in a controller, which you then graphically connect to the controls and they update automagically. These tutorials will show you the way.

俯瞰星空 2024-09-11 11:30:17

标签只是一个 NSTextField ,具有有关编辑/字体等的不同设置。只需在控制器中创建一个连接到 Interface Builder 中视图的插座,然后您就可以像更改任何其他 <代码> NSTextField 。

A label is just an NSTextField with different settings about editing/fonts, etc. Just make an outlet in your controller that connects to the view in Interface Builder, and you can change it like you would any other NSTextField.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文