NSTextField与Interface Builder中的自动NSNumberFormatter [英] NSTextField with automatic NSNumberFormatter in Interface Builder

查看:426
本文介绍了NSTextField与Interface Builder中的自动NSNumberFormatter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在做iOS应用程序,但我正在MacOS开发中尝试我的手。我添加一个NSTextField到我的UI,我注意到在Xcode图形小部件中的一个选项是NSTextField与NSNumberFormatter,这意味着我可以限制字段的输入数字和配置格式化器以某种方式。

I've been making iOS apps for awhile, but I'm trying my hand at MacOS development. I'm adding an NSTextField to my UI and I noticed in Xcode that one of the options in the graphical widgets is "NSTextField with NSNumberFormatter" which implies to me that I'll be able to restrict the input of the field to numbers and configure the formatter in some way.

当我添加NSTextField与NSNumberFormatter到我的UI,我可以看到它有一个格式化出口,似乎是一种链接到NSNumberFormatter(虽然名称是小灰色)。但是,我不能找出任何方式与交互或配置NSNumberFormatter。

When I add the NSTextField with NSNumberFormatter to my UI, I can see it has a formatter outlet which appears to be kind of linked to an NSNumberFormatter (although the name is a little grayed out). However, I can't figure out any way to interact with or configure that NSNumberFormatter.

任何帮助?

推荐答案

要访问NSNumberFormatter,在Dock中选择它(XCode 4 Interface Builder [IB]窗口左侧的对象列表)。

To access the NSNumberFormatter, you have to select it in the dock (that list of objects on the left side of the XCode 4 Interface Builder [IB] window).

如果底座不在大纲视图中,例如,它只显示大约4个图标,请单击底部的三角形在正方形按钮码头。现在,Dock应显示占位符部分和对象部分;

If the dock isn't in outline view, e.g., it just shows about 4 icons, click the triangle-in-a-square-button at the bottom of the dock. The dock should now show a "Placeholders" section and an "Objects" section; the objects are your UI objects in a hierarchical outline view.

在IB窗口中,单击您的NSTextField;将突出显示轮廓中相应的文本字段单元格(您可能需要旋转一些公开三角形才能看到它)。文本字段单元格应该具有公开三角形;旋转它,以显示数字格式化。选择它,你现在应该能够在检查器面板中操作它了。

In the IB window, click your NSTextField; that'll highlight the corresponding Text Field Cell in the outline (you may have to twiddle down some disclosure triangles to see it). The Text Field Cell should have a disclosure triangle; twiddle it down to reveal the Number Formatter. Select it, and you should now be able to manipulate it in the Inspector panel.

(有很多事情是不明显的,如XCode。 ,在Dock的大纲视图中检查你的UI对象,或者使用选择的对象来显示菜单。令人惊讶的是,它常常有用 - 你可以发现潜藏在那里!

(There are a lot of things non-obvious like that in XCode. When in doubt, examine your UI object in the Dock's outline view, or prowl the menus with that object selected. It's amazing--and often useful--what you can discover lurking there!

这篇关于NSTextField与Interface Builder中的自动NSNumberFormatter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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