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.
UITextView からテキストの最初の行を取得することは可能ですか? UITextView および NSString クラス リファレンスを調べましたが、これを実現できるメソッドが見つかりません。
これを達成する唯一の方法は、「NSString UIKit Additions Reference」で詳述されている複数行のテキスト メソッドを使用した反復プロセスです。文字列から最初の数単語を抽出し、" sizeWithFont:constrainedToSize:lineBreakMode:" が 1 単語だけの行の高さよりも高いサイズを返すまで、これらを徐々に合成し始めます。