NSTextField with automatic NSNumberFormatter in Interface Builder

前端 未结 2 1112
萌比男神i
萌比男神i 2021-01-12 05:44

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 th

相关标签:
2条回答
  • 2021-01-12 06:09

    to configure the number formatter, you can ( after you've selected the formatter ) open the Attributes inspector, select the behavior you want and customize the formatter. At least that worked for me in XCode 4.

    – moritz

    enter image description here

    0 讨论(0)
  • 2021-01-12 06:29

    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).

    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.

    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.

    (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!

    0 讨论(0)
提交回复
热议问题