Re: Best practices for associating UITextFields to UILabels
Re: Best practices for associating UITextFields to UILabels
- Subject: Re: Best practices for associating UITextFields to UILabels
- From: Chris Fleizach <email@hidden>
- Date: Fri, 27 Jan 2017 09:11:59 -0800
As you have surmised there is no titleUIElement in iOS which would impart this value.
I think the approaches you have taken to automatically pull the label from IB are reasonable.
You could also hide the UILabel and just duplicate the label on the text field
> On Jan 27, 2017, at 2:08 AM, Vincenzo Rubano <email@hidden> wrote:
>
> 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
_______________________________________________
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