AppleDeveloper is searching for a canonical reply:
Accessibility is a big subject and Apple documentation and WWDC movies are usually not protecting all matters
I’ve two views in a container view as under
@IBOutlet weak var dataDisclosureView: UIStackView! // Predominant ContainerView
@IBOutlet personal weak var titleLabel: UILabel! {
didSet {
titleLabel.textual content = “Good day”
}
}
@IBOutlet personal weak var descriptionLabel: UILabel! {
didSet {
descriptionLabel.textual content = “World”
}
}
@IBOutlet weak var descriptionView: UIStackView! { // sub container view containing titleLabel and descriptionLabel
didSet {
descriptionView.isAccessibilityElement = true
descriptionView.accessibilityLabel = “Good day”
descriptionView.accessibilityIdentifier = “test_hello”
}
}
@IBOutlet personal weak var requestButton: UIButton! {
didSet {
requestButton.isAccessibilityElement = true
requestButton.accessibilityLabel = “Request Button”
requestButton.accessibilityIdentifier = “test_button”
}
}
override func viewDidLoad() {
tremendous.viewDidLoad()
dataDisclosureView.isAccessibilityElement = false
dataDisclosureView.accessibilityElements = [ descriptionView ?? “” ]
if #out there(iOS 17.0, *) {
dataDisclosureView.automationElements = [ descriptionView ?? “”,
requestButton ?? “”]
} else {
// Fallback on earlier variations
}
let requestButtonAction = UIAccessibilityCustomAction(title: “begin”,
goal: self,
selector: #selector( request))
dataDisclosureView.accessibilityCustomActions = [ requestButtonAction ]
}
Mx subject is I would like AccessibilityIdentifers for descriptionLabel,titleLabel,requestButton and hintLabel(For Automation) and accessibility labels for descriptionView and requestButton(VoiceOver Accessibility).
However I’m unable to see accessibilityIdentifier for Button, TitleLabel and descriptionLabel in AccessibilityInspector. what am I doing unsuitable right here?
PS: I additionally adopted under video :
This can be a working answer
dataDisclosureView.accessibilityElements = [dataDisclosureView as Any,
titleLabel as Any,
descriptionLabel as Any,
requestButton as Any,
hintLabel as Any]
if #out there(iOS 17.0, *) {
dataDisclosureView.automationElements = [titleLabel as Any,
descriptionLabel as Any,
requestButton as Any,
hintLabel as Any]
} else {
// Fallback on earlier variations
}
however I’m not happy with that as a result of in one among Apple WWDC video it was talked about that if we would like exempt merchandise from voice over accessibility do not add it in accessibilityItems and if we would like in automation parts simply add it. They have not offered deeper particulars . Reference is https://www.youtube.com/watch?v=IAqzXI3kFCk additionally including screenshot about what I’m saying
In response to this it needs to be
dataDisclosureView.accessibilityElements = [dataDisclosureView as Any,
titleLabel as Any,
descriptionLabel as Any,
requestButton as Any]
if #out there(iOS 17.0, *) {
dataDisclosureView.automationElements = [titleLabel as Any,
descriptionLabel as Any,
requestButton as Any,
hintLabel as Any]
} else {
// Fallback on earlier variations
}