I have a UISwitch
inside tableviewcell. The toggle makes a network request. A UIActivityIndicator
replaces the switch until the response completes.
So the UX flow is as such:
off --> loader --> on
Before the label is tapped the accessibility reads as such:
label - value - hint
‘streaming - switch button off - double tap to toggle switch’
My code is as such:
@IBAction func switchToggled(_ sender: Any) {
toggle.isHidden = true
activityIndicatorView.startAnimating()
UIAccessibility.post(notification: .layoutChanged, argument: activityIndicatorView)
I've also disabled accessibility of the cell itself.
The problem is the accessibility will read as such:
$switchValue - activityIndicatorLabel-activityIndicatorValue - switchLabel switchValue
off - streaming - in progress - streaming - switch button on
I’m not sure why accessibility still reads after I’ve set the toggle’s isHidden
to true
and also posted an Accessibility notification ♂️
I want to omit off from above ☝️ and have it read as such:
$activityIndicatorLabel-activityIndicatorValue - switchLabel switchValue
streaming - in progress - streaming - switch button on
FWIW
UIAccessibility.post(notification: .screenChange, argument: activityIndicatorView)
Gets the desired sequence of voice, but then creates a new problem. That is I get the ‘boop beep’ sound and that would confuse a user into thinking they’re in a new screen.
It's quite odd that this notification moves to the correct item, while the other doesn't. I would have expected that both would create identical order but they don't
EDIT:
I've already looked into How to stop Text to Speech when Voiceover is speaking, or vice versa in Swift?
and I'm observing the UIAccessibilityElementFocusedNotification
notification. I get three items in the userInfo
.
▿ Optional<Dictionary<AnyHashable, Any>>
▿ some : 3 elements
▿ 0 : 2 elements
▿ key : AnyHashable("UIAccessibilityFocusedElementKey")
- value : "UIAccessibilityFocusedElementKey"
- value : <UIActivityIndicatorView: 0x113b59350; frame = (794 20; 24 24); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x2811a91e0>>
▿ 1 : 2 elements
▿ key : AnyHashable("UIAccessibilityAssistiveTechnologyKey")
- value : "UIAccessibilityAssistiveTechnologyKey"
- value : UIAccessibilityNotificationVoiceOverIdentifier
▿ 2 : 2 elements
▿ key : AnyHashable("UIAccessibilityUnfocusedElementKey")
- value : "UIAccessibilityUnfocusedElementKey"
- value : <MyModule.MySwitch: 0x113b59540; baseClass = UISwitch; frame = (769 16.5; 51 31); hidden = YES; opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x2811a9120>>
There are two things I don't know how to solve.
- The three events don't come in an orderly manner. It's just one single notification containing all three. I want to cancel the voiceOver for the switch is unfocused. I don't want that to be read.
- The answer still doesn't explain how to cancel the unwanted voiceOver.