Например, ошибка проявляется при выборе следующих строк:
Carnaroli, Maratelli, or Vialone Nano are best
Vialone Nano cooks quickly – watch it! It also absorbs condiments nicely.
Avoid Baldo, Originario, Ribe and Roma
Чтобы вызвать ошибку, выделите трехстрочный абзац с помощью курсора или клавиши со стрелками. Обратите внимание, что часть выделенного текста была заменена. Command-Z для отмены позволит вам повторить нежелательное поведение.
В этом случае «e Nano готовит быстро -» заменяется на « Baldo, Originario, Ribe."
Это происходит не со всеми строками или выбранными строками, но в тех случаях, когда это происходит, это прекрасно воспроизводится. На iOS этого не происходит. Содержимое монтажного стола не имеет значения. После неоднократного запуска ошибки в какой-то момент она перестает возникать.
Почему возникает эта ошибка? Как это можно исправить?
Снимки экрана, демонстрирующие поведение
Перед выбором:

После выбора:

Пример кода для воссоздания проблемы
@interface TestNoteViewController ()
@end
@implementation TestNoteViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self createTextView];
}
- (void)createTextView {
NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:self.note.text
attributes:nil];
NSTextStorage *textStorage = [NSTextStorage new];
[textStorage appendAttributedString:attrString];
CGRect newTextViewRect = self.view.bounds;
// Create the layout manager
NSLayoutManager *layoutManager = [NSLayoutManager new];
[textStorage addLayoutManager:layoutManager];
// Create a text container
NSTextContainer *container = [[NSTextContainer alloc] initWithSize:CGSizeMake(newTextViewRect.size.width, CGFLOAT_MAX)];
[layoutManager addTextContainer:container];
// Create and place a text view
UITextView *textView = [[UITextView alloc] initWithFrame:newTextViewRect
textContainer:container];
[self.view addSubview:textView];
textView.translatesAutoresizingMaskIntoConstraints = NO;
UILayoutGuide *safeArea = textView.superview.safeAreaLayoutGuide;
[textView.leadingAnchor constraintEqualToAnchor:safeArea.leadingAnchor].active = YES;
[textView.trailingAnchor constraintEqualToAnchor:safeArea.trailingAnchor].active = YES;
[textView.topAnchor constraintEqualToAnchor:safeArea.topAnchor].active = YES;
[textView.bottomAnchor constraintEqualToAnchor:textView.superview.bottomAnchor].active = YES;
}
@end
Подробнее здесь: https://stackoverflow.com/questions/782 ... c-catalyst