I have a custom view that has some subviews like labels and text fields. When I use multiple custom views into one controller I want to know the subview Accessibility Identifier. What I want to achieve is that set parent identifier(parent_accessibility_identifier) and than subview identifier can be an extension of it (eg parent_accessibility_identifier_label, parent_accessibility_identifier_text_field). Can we do this by setting the parent identifier accessibly to false and adding labels and text into the child's view but is there any better way to do it? this code doesn't work in the subview class.
public override var accessibilityIdentifier: String? {
didSet {
if let accessibilityIdentifier = self.accessibilityIdentifier {
self.accessibilityIdentifier = accessibilityIdentifier + "_label"
}
}
}
this work in the custom view class
public override var accessibilityIdentifier: String? {
didSet {
guard let accessibilityIdentifier = accessibilityIdentifier else { return }
textLabel.accessibilityIdentifier = accessibilityIdentifier + "_text_label"
}
}