浏览代码

convince ios to use the accessibilityHint

B. Petersen 5 年之前
父节点
当前提交
6a19d4e8ba
共有 1 个文件被更改,包括 9 次插入3 次删除
  1. 9 3
      deltachat-ios/Controller/ChatViewController.swift

+ 9 - 3
deltachat-ios/Controller/ChatViewController.swift

@@ -1094,8 +1094,6 @@ extension ChatViewController: MessagesLayoutDelegate {
         let cameraAction = PhotoPickerAlertAction(title: String.localized("camera"), style: .default, handler: cameraButtonPressed(_:))
         let documentAction = UIAlertAction(title: String.localized("documents"), style: .default, handler: documentActionPressed(_:))
         let voiceMessageAction = UIAlertAction(title: String.localized("voice_message"), style: .default, handler: voiceMessageButtonPressed(_:))
-        voiceMessageAction.accessibilityLabel = String.localized("voice_message")
-        voiceMessageAction.accessibilityHint = String.localized("a11y_voice_message_hint_ios")
         let isLocationStreaming = dcContext.isSendingLocationsToChat(chatId: chatId)
         let locationStreamingAction = UIAlertAction(title: isLocationStreaming ? String.localized("stop_sharing_location") : String.localized("location"),
                                                     style: isLocationStreaming ? .destructive : .default,
@@ -1109,7 +1107,15 @@ extension ChatViewController: MessagesLayoutDelegate {
             alert.addAction(locationStreamingAction)
         }
         alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
-        self.present(alert, animated: true, completion: nil)
+        self.present(alert, animated: true, completion: {
+            // unfortunately, voiceMessageAction.accessibilityHint does not work,
+            // but this hack does the trick
+            if UIAccessibility.isVoiceOverRunning {
+                if let view = voiceMessageAction.value(forKey: "__representer") as? UIView {
+                    view.accessibilityHint = String.localized("a11y_voice_message_hint_ios")
+                }
+            }
+        })
     }
 
     private func documentActionPressed(_ action: UIAlertAction) {