有誰知道一種方法來爲跨多個元素的可訪問性標籤跨越單個值嗎?我有兩個標籤組成一個標題行,屏幕閱讀器分別讀取它們。我試過選擇並應用設置,但它不起作用。界面生成器可訪問性標籤跨越多個元素
編輯:
這裏是我的故事板視圖...
然而,當屏幕閱讀器達到了這一點,它會讀取第一個標籤(未使用的無障礙值)然後是第二個標籤。
有誰知道一種方法來爲跨多個元素的可訪問性標籤跨越單個值嗎?我有兩個標籤組成一個標題行,屏幕閱讀器分別讀取它們。我試過選擇並應用設置,但它不起作用。界面生成器可訪問性標籤跨越多個元素
編輯:
這裏是我的故事板視圖...
然而,當屏幕閱讀器達到了這一點,它會讀取第一個標籤(未使用的無障礙值)然後是第二個標籤。
我最終解決這一問題......
我設置在第二的第一個元素,以「轉染搜索」,並清理和殘疾人無障礙設置的標籤值。這樣,屏幕閱讀器讀取第一項值,並完全跳過第二項。
它仍然只強調了第一個元素,但我不認爲有一種方法可以將元素分組並將可訪問性屬性應用於所有元素。
我們可以使用UIAccessibilityElement
類對元素進行分組,並使用accessibilityFrameInContainerSpace
屬性提供要分組的元素的組合框。
//From Apple Docs
let profileElement = UIAccessibilityElement(accessibilityContainer: headerView)
profileElement.accessibilityLabel = profileNameLabel.text
profileElement.accessibilityValue = openPostsLabel.text
profileElement.accessibilityTraits |= UIAccessibilityTraitButton // Tells VoiceOver to treat our new view like a button
let combinedLabelFrame = profileNameLabel.frame.union(openPostsLabel.frame)
let profileElementFrame = combinedLabelFrame.union(profileImageView.frame) //providing union of frames.
// This tells VoiceOver where the element is on screen so a user can find it as they touch around for elements
profileElement.accessibilityFrameInContainerSpace = profileElementFrame
檢查蘋果文檔Whats new in accessibility。
鏈接爲sample app解釋如何做到這一點。
嘿,你可以發佈一些代碼,截圖?任何解釋你的問題更多... –
不熟悉你正在使用的程序,但有沒有辦法將它們合併成一個元素或用一個元素包裝它們並將標籤指向那個? – gotohales