【发布时间】:2021-05-15 12:33:50
【问题描述】:
我有一个MKAnnotationView 子类,并将其中几个放在MKMapView 上。 MKAnnotationView 子类设置了一些可访问性元素,如下所示:
func applyAccessibility() {
self.isAccessibilityElement = true
self.accessibilityTraits = [.none]
self.accessibilityLabel = "Bus stop map pin"
self.accessibilityValue = busStop.name
}
VoiceOver 会读出固定在地图上的巴士站的名称。
然后我使用UIView 子类作为公共汽车站被点击时的标注视图。
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
if let annotation = view.annotation
{
if annotation is MKUserLocation
{
// This is our location marker
return
}
busStopAnnotationCalloutView.setupForAnnotationView(view, delegate: self)
view.addSubview(busStopAnnotationCalloutView)
mapView.setCenter(annotation.coordinate, animated: true)
}
}
这很好用,但是这个标注视图对 VoiceOver 完全不可见。
在我设置的标注视图的init中:
isAccessibilityElement = true
accessibilityTraits = .none
accessibilityLabel = "Callout view"
accessibilityIdentifier = "BusStopAnnotationCalloutView.callout"
它还创建了自己的标签和一个按钮,我设置的类似如下:
label.isAccessibilityElement = true
label.accessibilityTraits = .header
label.accessibilityLabel = "\(busStop.name)"
UI按钮
button.isAccessibilityElement = true
button.accessibilityTraits = .button
button.accessibilityLabel = "Select this bus stop"
但这些元素对 VoiceOver 都不可见。 Accessibility Inspector 看不到它们。
当我使用Accessibility Inspector 在视图中移动时,它只会拾取地图上标注下方的MKAnnotation。
编辑--------
我创建了一个小型示例项目,该项目具有自定义标注视图,但无法获得任何可访问性。
还有一个简短的屏幕录像显示问题:
【问题讨论】:
-
我无法下载您的示例,但我可以在我的项目中重现该问题。您是否尝试使用
UIAccessibilityContainer? stackoverflow.com/questions/26538359/…(还在我的待办事项清单上,抱歉) -
不,这个问题并不能真正解释它,但我会对此进行一些研究。
标签: ios accessibility mapkit mkmapview voiceover