Best practices for associating UITextFields to UILabels
Best practices for associating UITextFields to UILabels
- Subject: Best practices for associating UITextFields to UILabels
- From: Vincenzo Rubano <email@hidden>
- Date: Fri, 27 Jan 2017 11:08:30 +0100
Hi all,
this is a question on best practices rather than on how to fix things. :)
In my apps I often have use-cases where I need to show a text field with an associated label. From an accessibility point of view in these cases it makes sense to have the label text be the accessibilityLabel of the UITextField that it refers to. When developing Mac OS apps setting this relationship is trivial and can be done within the storyboard itself. In iOS, though, I haven’t found a way to do this within InterfaceBuilder…
So in order to associate a text field with a label I:
- Create an outlet for the label and the text field in my view controller;
- in viewDidLoad(), set explicitly the text field’s accessibilityLabel to the associated label text (which is guaranteed to be static, so I don’t need to observe its changes).
Is there a better way to accomplish the same result?
I’ve also considered the following alternatives:
1. subclassing UITextField adding an @IBInspectable property for its associated label, but I’m not a fan of subclassing UIKit controls)…
2. associating the label to the leftView property on the text field, but I’m not sure about the visual effects of this operation: I feel more confident in controlling the layout via constraints since as a blind I cannot rely on visual feedback to understand what’s going on in my interface.
Thoughts?
Vincenzo
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden