Skip to content

Commit

Permalink
修复在旁白开启状态下Toast内的信息无法被视障用户获取
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwjc authored Jun 30, 2020
1 parent f2fdc21 commit 6f4e8b9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions QMUIKit/QMUIComponents/QMUITips.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,24 @@ - (void)showTipWithText:(NSString *)text detailText:(NSString *)detailText hideA
} else if (delay > 0) {
[self hideAnimated:YES afterDelay:delay];
}

[self postAccessibilityAnnouncement:text detailText:detailText];
}

- (void)postAccessibilityAnnouncement:(NSString *)text detailText:(NSString *)detailText {
NSString *announcementString;
if (text) {
announcementString = text;
}
if (detailText) {
announcementString = announcementString ? [text stringByAppendingFormat:@", %@", detailText] : detailText;
}
if (announcementString) {
// 发送一个让VoiceOver播报的Announcement,帮助视障用户获取toast内的信息,但是这个播报会被即时打断而不生效,所以在这里延时1秒发送此通知。
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, announcementString);
});
}
}

+ (NSTimeInterval)smartDelaySecondsForTipsText:(NSString *)text {
Expand Down

0 comments on commit 6f4e8b9

Please sign in to comment.