简体   繁体   English

当呈现视图时,VoiceOver不会始终关注UILabel

[英]VoiceOver does not consistently focus on UILabel when when view is presented

We have a login screen with a UILabel hidden initially to represent a message when the user logs out of the app. 我们有一个最初隐藏UILabel的登录屏幕,用于表示用户退出应用程序时的消息。

When VoiceOver is turned on in iOS and the user tries to log out from the app, the voice over should ideally read out the logout message label. 当在iOS中打开VoiceOver并且用户尝试从应用程序注销时,理想情况下应该读出注销消息标签。 Instead, it reads out the password text field of the login screen. 相反,它会读出登录屏幕的密码文本字段。

The action of the log out button has the below implementation code. 注销按钮的操作具有以下实现代码。

let loginStoryboard = UIStoryboard(name: "Login", bundle: nil)
        let loginViewController = loginStoryboard.instantiateInitialViewController() as! LoginViewController
        loginViewController.modalPresentationStyle = UIModalPresentationStyle.CurrentContext
loginViewController.logOut = true
self.presentViewController(loginViewController, animated: true, completion:nil)

The logout indicator is set to display the logout message label. 注销指示器设置为显示注销消息标签。 LoginViewController viewDidLoad code. LoginViewController viewDidLoad代码。

if(!logOut){
            self.logOutMsg.hidden = true
}else{
            self.logOutMsg.text = NSLocalizedString("LoggedOutMsg", comment: "Logged out message")
            self.logOutMsg.hidden = false
}

The login screen fields are accessibility enabled in story board. 登录屏幕字段是故事板中启用的辅助功能。

The behavior is inconsistent: sometimes the logout message label is read and sometimes it reads out the password text field. 行为不一致:有时会读取注销消息标签,有时会读出密码文本字段。 Whenever VoiceOver reads the password text field, I can see an error in the console log. 每当VoiceOver读取密码文本字段时,我都会在控制台日志中看到错误。

 |error| Could not find <UIWindow: 0x124d13b10; frame = (0 0; 768 1024); gestureRecognizers = <NSArray: 0x174241140>; layer = <UIWindowLayer: 0x1742319c0>> in a list of sorted view [parent: <CaseworkerApp.AppDelegate: 0x124e008e0>] siblings (
        "<UILabel: 0x124d06cf0; frame = (132 1; 300 18); text = 'You are logged out of IBM...'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x1742921b0>>",
        "<CaseworkerApp.LoginTextField: 0x124da4890; baseClass = UITextField; frame = (80 37; 330 50); text = ''; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x1704551e0>; layer = <CALayer: 0x175033de0>>",
        "<CaseworkerApp.LoginTextField: 0x124d9bd50; baseClass = UITextField; frame = (80 110; 330 50); text = ''; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; tag = 1; gestureRecognizers = <NSArray: 0x17044dfb0>; layer = <CALayer: 0x175227ce0>>",
        "<UIButton: 0x124d52900; frame = (80 183; 330 50); autoresize = RM+BM; layer = <CALayer: 0x175039ae0>>"
    ).  If this happened right around a screen change, it might be okay, but otherwise this is probably a bug.
    2015-08-10 16:46:50.108 CaseworkerApp[2217:479225] |error| Could not find <UIWindow: 0x124d13b10; frame = (0 0; 768 1024); gestureRecognizers = <NSArray: 0x174241140>; layer = <UIWindowLayer: 0x1742319c0>> in a list of sorted view [parent: <CaseworkerApp.AppDelegate: 0x124e008e0>] siblings (
        "<UILabel: 0x124d06cf0; frame = (132 1; 300 18); text = 'You are logged out of IBM...'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x1742921b0>>",
        "<CaseworkerApp.LoginTextField: 0x124da4890; baseClass = UITextField; frame = (80 37; 330 50); text = ''; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x1704551e0>; layer = <CALayer: 0x175033de0>>",
        "<CaseworkerApp.LoginTextField: 0x124d9bd50; baseClass = UITextField; frame = (80 110; 330 50); text = ''; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; tag = 1; gestureRecognizers = <NSArray: 0x17044dfb0>; layer = <CALayer: 0x175227ce0>>",
        "<UIButton: 0x124d52900; frame = (80 183; 330 50); autoresize = RM+BM; layer = <CALayer: 0x175039ae0>>"
    ).  

If this happened right around a screen change, it might be okay, but otherwise this is probably a bug. 如果这发生在屏幕更改周围,它可能没问题,但否则这可能是一个错误。

Any help please to resolve this? 有任何帮助请解决此问题?

When a view is presented, VoiceOver starts reading from the first element in the accessibility tree. 显示视图时,VoiceOver将从辅助功能树中的第一个元素开始读取。 There are possibly two solutions. 可能有两种解决方案。

First, you can modify the order. 首先,您可以修改订单。

Change order of read items with VoiceOver 使用VoiceOver更改已读项目的顺序

Secondly, you can make VoiceOver to focus on a particular element when a view changes by posting ScreenChanged Notification from UIAccessibility indicating which element VoiceOver should focuss. 其次,通过从UIAccessibility发布ScreenChanged Notification指示VoiceOver应该关注哪个元素,您可以使VoiceOver在视图更改时专注于特定元素。

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

Read more information from the documentation. 阅读文档中的更多信息。

UIAccessibility.post: https://developer.apple.com/documentation/uikit/uiaccessibility/1615194-post UIAccessibility.post: https://developer.apple.com/documentation/uikit/uiaccessibility/1615194-post

UIAccessibility.Notification: https://developer.apple.com/documentation/uikit/uiaccessibility/notification UIAccessibility.Notification: https//developer.apple.com/documentation/uikit/uiaccessibility/notification

screenChanged: https://developer.apple.com/documentation/uikit/uiaccessibility/notification/1620198-screenchanged screenChanged: https//developer.apple.com/documentation/uikit/uiaccessibility/notification/1620198-screenchanged

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

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