0

请参考以下代码:

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 在分配后更改其可访问性标签吗?

谢谢,

-希尔皮

4

3 回答 3

1

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

alertObj.accessibilityTraits =   UIAccessibilityTraitUpdatesFrequently;

谢谢

于 2014-10-07T09:25:01.470 回答
0

您可以更改子视图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.

于 2013-01-24T09:28:35.037 回答
0

使用这种方式设置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

于 2013-01-24T08:37:23.463 回答