简体   繁体   中英

Set VoiceOver to ignore placeholder text in UITextField?

I have a UITextField for the user to enter their phone number. The placeholder text for the field is (XXX) XXX-XXXX. For sighted users, this works great, but with VoiceOver turned on, it sounds pretty bad to just read out all the X's.

I have accessibilityLabel set to "Phone Number" and accessibilityHint set to "Requires 10-digit phone number". Right now, VoiceOver will read the label, then placeholder text, then the hint. Is it possible to set VoiceOver to ignore the placeholder text?

I was able to work around this by removing the label and then changing the placeholder text when VoiceOver is turned on:

if UIAccessibilityIsVoiceOverRunning() {
    phoneNumberField.placeholder = "Phone Number"
}

Now, it will just read the placeholder text and then the accessibility hint. I feel like this is a bit of a hacky solution though. So, if there is a way to have VoiceOver ignore certain pieces of information, that would be more ideal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM