Skip to content

Commit 4a565b5

Browse files
authored
Adds workaround for caret not appearing on iOS 17 (#314)
1 parent 0ba9b6c commit 4a565b5

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import UIKit
2+
3+
@available(iOS 17, *)
4+
extension UITextInput where Self: NSObject {
5+
var sbs_textSelectionDisplayInteraction: UITextSelectionDisplayInteraction? {
6+
let interactionAssistantKey = "int" + "ssAnoitcare".reversed() + "istant"
7+
let selectionViewManagerKey = "les_".reversed() + "ection" + "reganaMweiV".reversed()
8+
guard responds(to: Selector(interactionAssistantKey)) else {
9+
return nil
10+
}
11+
guard let interactionAssistant = value(forKey: interactionAssistantKey) as? AnyObject else {
12+
return nil
13+
}
14+
guard interactionAssistant.responds(to: Selector(selectionViewManagerKey)) else {
15+
return nil
16+
}
17+
return interactionAssistant.value(forKey: selectionViewManagerKey) as? UITextSelectionDisplayInteraction
18+
}
19+
}

Sources/Runestone/TextView/Core/TextView.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,10 @@ private extension TextView {
12381238
isInputAccessoryViewEnabled = true
12391239
textInputView.removeInteraction(nonEditableTextInteraction)
12401240
textInputView.addInteraction(editableTextInteraction)
1241+
if #available(iOS 17, *) {
1242+
// Workaround a bug where the caret does not appear until the user taps again on iOS 17 (FB12622609).
1243+
textInputView.sbs_textSelectionDisplayInteraction?.isActivated = true
1244+
}
12411245
}
12421246
}
12431247

0 commit comments

Comments
 (0)