【问题标题】:Accessibility: On updating UIAlertView's message, the text that Voice over reads does not change?辅助功能:更新 UIAlertView 消息时,Voiceover 读取的文本不会改变?
【发布时间】:2013-01-24 08:34:30
【问题描述】:

请参考以下代码:

UIAlertView *progressAlertView = [[UIAlertView alloc] 
                                  initWithTitle:@"Title"
                                  message:@"Message"  
                                  delegate:self 
                                  cancelButtonTitle:@"Cancel"
                                  otherButtonTitles:nil];


progressAlertView.message=@"Hello, I am the new one";

旁白总是读取“消息”,而从不读取第二行“你好,我是新消息”中设置的新消息字符串。无法更改 UIAlertView 的 bodyTextLabel 控件/子视图的此可访问性标签。

知道如何让 UIAlertView 在分配后更改其可访问性标签吗?

谢谢,

-希尔皮

【问题讨论】:

    标签: ios accessibility uialertview


    【解决方案1】:

    您可以使用 accessibilityTraits 作为 UIAccessibilityTraitUpdatesFrequently 来阅读更新的消息。 它的工作原理是:

    alertObj.accessibilityTraits =   UIAccessibilityTraitUpdatesFrequently;
    

    谢谢

    【讨论】:

      【解决方案2】:

      用这种方式设置UIAlertView

      的消息
      UIAlertView *progressAlertView = [[UIAlertView alloc] 
                                        initWithTitle:@"Title"
                                        message:@"Message"  
                                        delegate:self 
                                        cancelButtonTitle:@"Cancel"
                                        otherButtonTitles:nil];
      
      
      [alertView setMessage:@"Hello, I am the new one"];
      [alertView show];
      

      有关 UIAlertView 的更多信息,请参阅此 http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAlertView_Class/UIAlertView/UIAlertView.html

      【讨论】:

      • 我已经阅读了您上面提到的文档。供您参考 alertView.message=@"abc" 和 [alertView setMessage:@"abc"];是一样的。
      【解决方案3】:

      您可以更改UIAlertView 的子视图以更改可访问性标签等单个属性:

      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Test"
                                                      message:@"Message"
                                                     delegate:nil
                                            cancelButtonTitle:@"Ok"
                                            otherButtonTitles:nil];
      
      // In a standard UIAlertView there are 2 UILabels and some buttons
      // The UILabel with the message is always the 2nd object in the array
      NSArray *subviews = alert.subviews;
      UILabel *messageLabel = [subviews objectAtIndex:1];
      [messageLabel setAccessibilityLabel:@"Some other text"];
      

      使用此代码,您只需更改辅助功能标签,以便 VoiceOver 读取另一个文本但显示旧文本。

      在您的情况下,您应该将可访问性标签设置为与您要设置UIAlertView 的消息相同。

      【讨论】:

      • Apple 不推荐访问内部视图,事实上,如果您使用这样的东西,可能会拒绝您的应用程序。
      • Apple Bug ID# 13095288 已被记录以跟踪此问题
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多