簡體   English   中英

輔助功能:更新UIAlertView的消息時,旁白讀取的文本不會更改嗎?

[英]Accessibility: On updating UIAlertView's message, the text that Voice over reads does not change?

請參考以下代碼:

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


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

旁白總是讀取“消息”,而從不讀取第二行“您好,我是新消息”中設置的新消息字符串。 無法更改UIAlertView的bodyTextLabel控件/ subView的此可訪問性標簽。

任何想法如何使UIAlertView在分配后更改其可訪問性標簽?

謝謝,

-希爾皮

您可以經常將accessibilityTraits用作UIAccessibilityTraitUpdates來讀取更新的消息。 它的工作原理是:

alertObj.accessibilityTraits =   UIAccessibilityTraitUpdatesFrequently;

謝謝

使用這種方式來設置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

您可以更改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消息相同的標簽。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM