Ios 当显示视图时,画外音不会始终关注UILabel
我们有一个带有Ios 当显示视图时,画外音不会始终关注UILabel,ios,objective-c,swift,accessibility,uiaccessibility,Ios,Objective C,Swift,Accessibility,Uiaccessibility,我们有一个带有UILabel的登录屏幕,最初是隐藏的,用于在用户注销应用程序时表示消息 当在iOS中打开VoiceOver并且用户试图从应用程序注销时,VoiceOver最好能读出注销消息标签。相反,它读取登录屏幕的密码文本字段 注销按钮的操作具有以下实现代码 let loginStoryboard = UIStoryboard(name: "Login", bundle: nil) let loginViewController = loginStoryboard.instan
UILabel
的登录屏幕,最初是隐藏的,用于在用户注销应用程序时表示消息
当在iOS中打开VoiceOver并且用户试图从应用程序注销时,VoiceOver最好能读出注销消息标签。相反,它读取登录屏幕的密码文本字段
注销按钮的操作具有以下实现代码
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)
注销指示器设置为显示注销消息标签。
LoginViewController
viewdiload
code
if(!logOut){
self.logOutMsg.hidden = true
}else{
self.logOutMsg.text = NSLocalizedString("LoggedOutMsg", comment: "Logged out message")
self.logOutMsg.hidden = false
}
登录屏幕字段在故事板中启用了可访问性
行为不一致:有时读取注销消息标签,有时读取密码文本字段。
每当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>>"
).
| error |在排序视图[父项:]的列表中找不到(
"",
"",
"",
""
).如果这正好发生在屏幕更改附近,可能没问题,但否则这可能是一个错误。
2015-08-10 16:46:50.108 CasewerApp[2217:479225]|错误|在排序视图[父项:]的列表中找不到(
"",
"",
"",
""
).
如果这发生在屏幕更改的附近,可能没什么问题,但除此之外,这可能是一个bug
请提供任何帮助以解决此问题?当显示视图时,VoiceOver将从辅助功能树中的第一个元素开始读取。可能有两种解决方案 首先,您可以修改订单 其次,当视图发生变化时,您可以通过发布UIAccessibility的ScreenChanged通知,指示VoiceOver应该关注哪个元素,从而使VoiceOver关注某个特定元素
UIAccessibility.post(notification:.screenChanged, argument:elementToBeFocussed)
阅读文档中的更多信息
UIAccessibility.post:
11.通知:
屏幕更改: