Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
NSTextViewがあり、ユーザーの操作時にビューを表示するために挿入ポイントの座標が必要です。
NSPointから文字インデックスを取得する機能があります。反対の簡単な方法はありますか?
助けてくれてありがとう!
もちろん:[textView firstRectForCharacterRange:[textView selectedRange]];
[textView firstRectForCharacterRange:[textView selectedRange]];
NSTextViewサブクラス -drawInsertionPointInRect:color:turnedOn:を使用して、図面rectをキャッシュするようにオーバーライドし、rectの中心(または他の内部ポイント)を使用して、これを実行できる場合があります。
-drawInsertionPointInRect:color:turnedOn:
NB:私はこれを試していません。