gpt4 book ai didi

ios - 呈现 View 时,VoiceOver 不会始终关注 UILabel

转载 作者:搜寻专家 更新时间:2023-10-30 22:19:01 24 4
gpt4 key购买 nike

我们有一个登录屏幕,其中最初隐藏了一个 UILabel 以表示用户注销应用程序时的消息。

当在 iOS 中打开 VoiceOver 并且用户尝试从应用程序注销时,画外音最好读出注销消息标签。相反,它会读出登录屏幕的密码文本字段。

注销按钮的 Action 有以下实现代码。

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 viewDidLoad 代码。

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

登录屏幕字段在 Storyboard中启用了辅助功能。

行为不一致:有时会读取注销消息标签,有时会读取密码文本字段。每当 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>>"
).

如果这发生在屏幕更改前后,可能没问题,否则这可能是一个错误。

请帮忙解决这个问题?

最佳答案

呈现 View 时,VoiceOver 从辅助功能树中的第一个元素开始读取。可能有两种解决方案。

首先,您可以修改订单。

Change order of read items with VoiceOver

其次,您可以通过从 UIAccessibility 发布 ScreenChanged Notification 指示 VoiceOver 应该关注哪个元素,从而使 VoiceOver 在 View 更改时关注特定元素。

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

从文档中阅读更多信息。

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

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

屏幕已更改:https://developer.apple.com/documentation/uikit/uiaccessibility/notification/1620198-screenchanged

关于ios - 呈现 View 时,VoiceOver 不会始终关注 UILabel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31918557/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com