@simonbs @lextar @steveshepard Curious if you experience the same: When setting the new inlinePredictionType to yes, the prediction is triggered via setAttributedMarkedText. But when setting the marked range, the insertion caret disappears and does not re-appear even when removing and re-adding the UITextInteraction.
@knutknatter @simonbs Seeing the same thing. The caret disappears after inserting the attributed marked text. For me, it reappears after a tap. It looks like _UICursorAccessoryHostView is hidden after this call. I'll file a Feedback tomorrow AM.
@steveshepard @knutknatter I wonder if we avoid these bugs if we adopt the new UITextSelectionDisplayInteraction iOS 17. I’m going to try that one of the next few days.
@simonbs @steveshepard Wondering the same. Really didn’t want to have to go this route. I might try the same.

@knutknatter @steveshepard The "What's new with text and text interactions" session from WWDC seems to suggest that using UITextInteraction is still preferred.

On adopting the redesigned UI of the caret and text selection, the engineer says “If you have a highly customized UI for displaying text, it can be challenging to keep up with these changes in your own implementation, especially if you aren't able to adopt UITextInteraction”.

@knutknatter @steveshepard I've just made a quick test with UITextSelectionDisplayInteraction and with the new API I'm no longer seeing the bug where the text selection handles are placed incorrectly on visionOS: https://mastodon.social/@simonbs/110903512345493534

So Apple is suggesting that UITextInteraction is preferred but it's exhibiting bugs that UITextSelectionDisplayInteraction isn't. Now, I have yet to discover which bugs UITextSelectionDisplayInteraction exhibits 😄

@knutknatter @steveshepard For some reason UITextSelectionDisplayInteraction draws selection handles and the caret below the text though. That's a bit awkward. I'm also not sure how to combine this with a non-editable interaction that allows users to select text only.
@knutknatter @steveshepard Apparently UITextInteraction also places these views below the text on iOS 17 so maybe this is an issue in my side.

@simonbs @knutknatter Are you providing a selection container? If not, this might help:

- (nullable UIView *)selectionContainerViewBelowTextForSelectionDisplayInteraction:(UITextSelectionDisplayInteraction *)interaction;

@steveshepard @knutknatter I was playing around with that but never got the views to be on top of the text. It seemed like even if I returned a view, the caret and selection handles were added to the same view as the interaction. Anyway, I think I’ve already given up on UITextSelectionDisplayInteraction as it seems there are a few gestures we aren’t getting for free like we do with UITextInteraction.

@simonbs @knutknatter The interaction also tests for the private vars "selectionContainerView" and "_selectionContainerViewAboveText". Worth a try?

Per the earlier discussion, note also the "becomesEditableWithGestures" and "playsNicelyWithGestures" private vars. It looks like there is a rats nest of compatibility code in UITextInteraction. I feel bad for James.

@steveshepard @knutknatter Ouch. It’s a frustrating situation right now. I really can’t figure out what we’re supposed to do. UITextInteraction has some new and bad bugs in iOS 17. If these aren’t fixed before the release, it’s really bad.
@simonbs @steveshepard I’m curious what gestures did you notice were missing?
@knutknatter @steveshepard I didn't spend a lot of time with UITextSelectionDisplayInteraction and I don't remember the exact results. However, I seem to recall that gestures such as moving the caret and adjusting the selection weren't provided for free -- though as I’m writing this, I it would seem odd that those gestures were absent 🤔
@simonbs @steveshepard That does seem strange. But so is the disappearing caret in UITextInteraction. Haha. Considering having a look at this myself...
@simonbs @steveshepard “ If you want to implement the selection gestures yourself, but still want to indicate text selection using the standard system UI, use UITextSelectionDisplayInteraction instead.” https://developer.apple.com/documentation/uikit/keyboards_and_input/adopting_system_selection_ui_in_custom_text_views
Adopting system selection UI in custom text views | Apple Developer Documentation

Incorporate the system text-selection experience into your custom text UI in UIKit.

Apple Developer Documentation
@knutknatter @steveshepard Right, I also remember that the WWDC session mentions that using the new interaction means giving up on some gestures. I really don’t want to implement these myself.
@simonbs @steveshepard agreed. Keeping up with potentially new gestures year after year would also be pain.
@knutknatter @simonbs Feedback is down for me, so I'll try again later. A quick update to say that _UICursorAccessoryHostView was a red herring. The real issue is that _UITextCursorView is removed after setting the attributed marked text.
@steveshepard @knutknatter I'm seeing the same thing. _UITextCursorView is removed from the view hierarchy when setting the marked range.
@steveshepard @knutknatter I see that this has been an issue for me before and I have this code snippet to work around it. I call this function at the end of setAttributedMarkedText(_:selectedRange:) but as Till said, even this doesn't address the issue on iOS 17.
@simonbs @steveshepard Still does not work in latest beta, correct?
@knutknatter @steveshepard Yes. Both the issue where the caret does not appear when swapping out an non-editable UITextInteraction with an editable UITextInteraction and the issue where the caret disappears after setAttributedMarkedText(_:selectedRange:) seems to be present in beta 7 too 😞
@simonbs @steveshepard nothing fixed in beta 8 it seems
@knutknatter @simonbs I don't see any action on the Feedback I submitted (FB13024851), It's still open with no similar reports. Let me know if you filed one too, and I'll add a reference in my report.