NSNumberFormatter through StoryBoard - Xcode 9 - cocoa

I want to implement NumberFormatter through Storyboard, for currency inputs in textfields.
I have referred to these answers: https://stackoverflow.com/a/7479950/7205816
https://stackoverflow.com/a/30688762/7205816
This makes me believe that it was there in earlier Xcode versions. Is it the same case now? How can we implement it in storyboard?
If we do it through code, the issue I am facing is that I convert it into comma separated string, but need to save the same without commas.
What is the correct way to achieve the same?

NSNumberFormatter is only available for mac apps. To have the same behavior on iOS you should do it programmatically.
In Xcode 10:
In the UI components Library, search for Text Field with Number Formatter
Then in the scene explorer, select the Number Formatter:
In the Attributes Inspector, you could set the properties of the number formatter:
On Xcode 9 and lower, you can find the UI Elements in your storyboard by toggling the inspector panel:

Related

Xamarin.iOS dynamically ScrollView

I really need your help.
I'm new at developing Xamarin.iOS apps and now I'm totally stuck.
I cannot get the hang of how to implement a dynamic ScrollView in iOS, it was fairly easy to implement on Android.
So what I'm trying to implement is a view that contains mostly text (that will be quite long, hence the scrolling, but also two buttons.
Here is a gif in Android showing what I'm trying to achieve
The view is like this:
Header
Long text
Copyright button
-- Copyright text
Terms of usage button
-- Terms of usage text
I have struggled with the scrolling so long and I really need your help.
All of the text properties are getting bound to the view by binding with MvvmCross so the view can't be with hard-coded heights and widths, it needs to adjust properly.
Can somebody please show me with a sample project how to implement it?
The view needs to be in a .xib view (because of MvvmCross) and it cannot contain a UIViewcontroller.
So the solution needs to be in a simple UIView
I'm working on a Windows, with Visual Studio 2015 enterprise, and I cannot use a Mac (and Xcode) other than to compile my code with.
What I've tried is a solution like this:
UIView called "MyRootview"
-- UIScrollView called "MyScrollView"
-- -- UIView called "MyContentView"
Can you please help me?
Method 1:
Use a TableView instead of ScrollView. Make the header row 1, long text row 2, button 1 and it's text row 3 and button 4 and it's text row 4.
Give row height for the last 2 rows so that you only see the button and on button click increase the row height and reload the table section.
Method 2:
If you keep wanna using ScrollView, put the button data in a label and give it a height of 0 (and number of lines 1) to hide it and on button click remove the height constraint and set the number of lines to 0 (max).
I used FluentLayout instead. Very easy.
https://github.com/FluentLayout/Cirrious.FluentLayout

How to obtain reference to TextField in UI Tests in Xcode 7

I am trying to use UI tests in Xcode 7 beta.
I have a storyboard with two text fields. Both text fields have outlets and different Restoration IDs. I recorded the test but generated code is quite unreadable and it doesn't work:
app.otherElements.containingType(.TextField, identifier:"y").childrenMatchingType(.TextField).elementBoundByIndex(0).typeText("hello")
I also tried the following and will work based on Placeholder text?!?
app.textFields["PlaceholderText"].typeText("hello")
What is the right way to obtain a reference to a TextField in UI tests?
You need to set accessibility identifier in storyboard for that particular textField. Check the image below :
So you can query textField using accessibility identifier like this :
let app = XCUIApplication()
app.launch()
let nameTextField = app.textFields["nameTextField"]
nameTextField.tap()
nameTextField.typeText("Hello John")

In Xcode Interface Builder how do I control how the element behave when the view is resized?

In older Xcode I have a little window where I could mark braces and band things to control how a NSView behaves when its parent is resized. In the new Xcode that is missing and the controls are doing whatever they feel like.
Is there any way to get this control back? (current version: Version 4.3.2 (4E2002))
Starting with Xcode 4.3 when you create a Cocoa application project, the xib file uses auto layout. Auto layout replaces the size inspector's autosizing mask.
If you want to use the autosizing mask, the solution is to turn off auto layout. Select the xib file from the project navigator, open the file inspector, and deselect the Use Auto Layout checkbox.
Read Constraints Express Relationships Between Views to learn how views are constrained in Xcode 4. In fact, you probably want the entire Cocoa Auto Layout Guide.
Briefly, when you add a view to your view hierarchy, it comes with some constraints. Select the view in the and you'll see some blue lines that look a bit like I-beams -- these represent the constraints. Click on one of them and you can edit its properties in the attributes inspector. But how you should set the attributes probably won't make much sense until you've read about how constraints work in the document linked above.

Accessibility in Interface Builder in Xcode 4.3

I was wondering if anyone knows where the accessibility view in Xcode 4.3 is?
This is what I see in my IB; no tab for accessibility.
EDIT:
UITableView doesn't have an accessibility drop down because the items inside it (the cell, or actually the label and the buttons and whatever else you put into a custom table view cell) will be the accessibility items the user is looking for.
Original answer:
The accessibility label is available on many various UIView subclassed objects (such as controls like buttons).
If you're looking at the detail for any object in XCode 4's XIB / Interface Builder editor, you'll see a drop down field that looks like the below:

NSTextField with automatic NSNumberFormatter in Interface Builder

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.
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.
Any help?
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!
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

Resources