简体   繁体   English

用于自定义视图的iOS配音通过uiviewcontroller显示

[英]iOS voiceover for custom view displayed over uiviewcontroller

I have a UIViewController let's call it MainViewController, a child controller instance (ChildViewController of type UITableViewController) is added to MainViewController the accessibility of the ChildViewController is set and voiceover works fine for the same. 我有一个UIViewController,我们称它为MainViewController,一个子控制器实例(类型为UITableViewController的ChildViewController)被添加到MainViewController中,设置了ChildViewController的可访问性,并且画外音同样适用。

MainViewController has a toolbar button, on tap a custom view will be displayed as shown below MainViewController有一个工具栏按钮,点击后将显示一个自定义视图,如下所示

//CustomView class
func show() {
    UIView.animate(withDuration:0.5, delay: 0.0, usingSpringWithDamping: 0.8, initialSpringVelocity: 5, options: .curveEaseInOut, animations: {
        self.disabledLayer.backgroundColor = UIColor.init(white: 0, alpha: 0.55)
        self.transform = .identity
    }, completion: {
        (value: Bool) in
        self.accessibilityElements = [titleLabel, closeButton] // titleLabel, closeButton are added dynamically to the view and are of type UILabel and UIButton respectively
    })
}

by doing this the voiceover never used to reach(read) the custom view elements. 通过这样做,画外音就永远不会到达(读取)自定义视图元素。 after some research added below line to MainViewController in toolbar button tap handler 经过一些研究后将以下行添加到工具栏按钮点击处理程序中的MainViewController

UIAccessibility.post(notification: .screenChanged, argument: actionView)

after this the voiceover starts reading the elements in the Custom View and can be navigated through elements using left and right swap. 此后,画外音开始读取“自定义视图”中的元素,并且可以使用左右交换在元素之间导航。

But the issue is when i tap on any of the element in the CustomView it is not selected and read, instead the elements of ChildViewController which is in the background is selected and read at that tap position. 但是问题是,当我点击CustomView中的任何元素时,都不会选择并读取它,而是选择了在后台的ChildViewController元素并在该点击位置读取。

On Swap, works as expected 交换时,按预期工作

交换时,按预期工作

Issue - when tapped on close button, the element in the childview controller which is in the background is selected 问题 -点击“关闭”按钮时,处于背景的childview控制器中的元素被选中

问题-点击“关闭”按钮时,处于背景的childview控制器中的元素被选中

Note: the CustomView has a child view with semi transparent background Color 注意:CustomView的子视图具有半透明的背景颜色

Thanks in advance 提前致谢

The custom view is a modal view which is displayed on top of the current uiviewcontroller. 自定义视图是模式视图,显示在当前uiviewcontroller的顶部。

Have added below line to CustomView which solved the issue. 已将以下行添加到解决问题的CustomView中。

self.accessibilityViewIsModal = true

Here VoiceOver would ignore the elements within views that are siblings of the receiver. 在这里,VoiceOver将忽略视图中作为接收者同级的元素。

Refer Apple's doc for more details 请参阅Apple的文档以获取更多详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM