ios - 如何在 Swift 中为 UIRefreshControl 添加可访问性

标签 ios swift uirefreshcontrol uiaccessibility xcode9.2

我正在尝试为 UIRefreshControl 添加可访问性,它已实现用于在 UITableView 中拉动刷新,如下所示

self.refreshControl.accessibilityLabel = "Refreshing"

但是,如果辅助功能已打开并通过在 UITableview 上滑动三个手指,则不会说是刷新。

我重写了 accessibilityScroll 方法,如下所示。

override func accessibilityScroll(_ direction: UIAccessibilityScrollDirection) -> Bool {
    if direction == .up {
        self.refreshControl.accessibilityLabel = "Refreshing"
    }
    return true
}

任何想法谢谢!

最佳答案

首先,刷新不仅仅是向上滚动。它向上滚动超过 y 位置 0。否则,只要用户向上滚动,就会发生这种情况。其次,使用 UIAccessibilityPostNotification 向用户宣布 UI 元素刚刚更改。

关于ios - 如何在 Swift 中为 UIRefreshControl 添加可访问性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51522686/

相关文章:

ios - 使用 NSDictionary 对象从数组中获取对象

ios - 如何在 iOS 应用程序中将录制的语音设置为通知声音?

swift - 无法显示 UIBezierPath

ios - 给 UIRefreshControl 一个顶部插图

iphone - 实现一个水平的UIRefreshControl

uitableview - UIRefreshControl 在 uitableview 中重叠 headerview

ios - Mapbox仅加载国家/地区 map

ios - 以编程方式通过内容的摘要高度设置 uiview 高度,并将其添加到容器并调整其大小

ios - MKMapView 防止注解分组

ios - WatchOS2中使用NSTimeInterval触发通知