UITextViewがあり、UITextView.textの最後にある単語を次のコードのように置き換えます。
-(void)replaceTextViewWithWord:(NSString *)word {
NSString *currentTextViewText = self.textView.text;
currentTextViewText = [currentTextViewText stringByReplacingCharactersInRange:NSMakeRange([self.textView.text length] - [word length], [word length]) withString:word];
self.textView.text = currentTextViewText;
}
交換作業は問題ありませんが、textViewが長くなると、実行速度が非常に遅くなります。
他にもっと良い方法はありますか?
replaceRange:withTextを1週間試してみましたが、それでもスタックします。私の場合、それを使用して交換する方法がわかりません。
案内してください!前もって感謝します!それは緊急の課題です。