Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: Accessibility support for dynamic labels / validation errors?

I want to enable accessibility support in my app where i have In-line validation message (e.g As per below screenshot) when user enters something invalid data. My app doesn't show any error message.

What can be best and intuitive way to inform visual impaired/blind user about wrong data entries. e.g. Username & password mismatch, invalid.

enter image description here

like image 812
harshit2811 Avatar asked Mar 18 '23 04:03

harshit2811


1 Answers

First off, there is no "correct" way to do this. There are just a bunch of ways that work. The "best" way to do this, would be for iOS to have a "required" trait (IMO). But this is not supported, so we have to work with what iOS has given us... hints and labels.

Step 1:

Tell the user what is required. I would do this by adding the information to the hint. I like to add information to the hint that only non-familiar users need. "Power users" of your application will get use to what fields are required (assuming you're going to have return users, some views are just "hit and run" types). But, point being, don't flood users with unnecessary information. Users who visit a particular view frequently will get use to what is required, so keep non-crucial information in the hint. What you want is voiceover to read out the text input fields like this: "Email(accessibilityLabel) text field (the type of object), (pause) This field is required.(hint)" Don't wait until after a failure to provide this information to VoiceOver users. It should just always be set this way. If the type of failure changes, change the hint to adapt to this particular type of failure. If you'd like to keep the hint in sync with the Red highlighted labels, you can consider overriding the functions from the UIAccessibilityProtocol to pull out this information EX:

- (NSString*)accessibilityHint {
    return myUILabel.text;
}

This should cause to keep the hint of the object, and the text of your UILabel in sync.

Step 2:

Mark all elements that are not the text input fields, as not accessibility elements. All of the information a user needs about those fields is either stored in the type of the field (a text input field), the label (email/password), or the hint (whether or not it is required). Therefore, we don't want VoiceOver to look at the other elements, because this would be duplicate information.

Step 3:

Use the following line of code:

UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, anAccessibilityElement);

In your login action. On a failed login action, you should shift voiceover focus to the element that caused the failure. This informs the user that their action was attempted, and that it failed. It also allows them to easily know which element caused the failure, and that it needs fixed. In the event of multiple failures, make sure you shift focus to the first failure!

like image 156
ChrisCM Avatar answered Apr 06 '23 12:04

ChrisCM