Issue with UITextView Popup Menu Not Appearing in Xcode 16 on iOS 18.0+

In the app we are developing, we are referencing the UITextView layoutManager in a ViewController method.

However, the popup menu that appears when long tapping on a text field cannot be displayed.

This occurs in apps built with Xcode16 (iOS 18.0 or higher).

On the other hand, this does not occur in apps built with Xcode15 (iOS 18.0 or higher).

What is the cause? Please let me know how to fix it.

SampleViewController.h
@property (weak, nonatomic) IBOutlet UITextView *textField;

SampleViewController.m
- (void)viewWillLayoutSubviews {
    [super viewWillLayoutSubviews];
    self.textField.layoutManager;
}
Answered by DTS Engineer in 823443022

When you access the layoutManager property of UITextView, the text view falls back from TextKit2 to TextKit1, which I believe is the culprit of the issue you described. The reason that building with Xcode 15 doesn't trigger the issue is probably because the storyboard built with Xcode 15 is still default to TextKit1, and so no fallback happens.

Is there any strong reason that you need to use layoutManager? If not, I'd suggest that you use textLayoutManager instead, which is a part of TextKit2.

If you do need layoutManager, consider accessing it earlier. Retrieving the property in viewDidLoad should be fine.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

When you access the layoutManager property of UITextView, the text view falls back from TextKit2 to TextKit1, which I believe is the culprit of the issue you described. The reason that building with Xcode 15 doesn't trigger the issue is probably because the storyboard built with Xcode 15 is still default to TextKit1, and so no fallback happens.

Is there any strong reason that you need to use layoutManager? If not, I'd suggest that you use textLayoutManager instead, which is a part of TextKit2.

If you do need layoutManager, consider accessing it earlier. Retrieving the property in viewDidLoad should be fine.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Issue with UITextView Popup Menu Not Appearing in Xcode 16 on iOS 18.0+
 
 
Q