开发者

Get text from UITextView

开发者 https://www.devze.com 2022-12-24 04:23 出处:网络
Is it possible to get the first line of text fr开发者_JS百科om a UITextView. I have looked through the UITextView and NSString Class References and can\'t find any methods that could accomplish this.

Is it possible to get the first line of text fr开发者_JS百科om a UITextView. I have looked through the UITextView and NSString Class References and can't find any methods that could accomplish this.


The only way to accomplish this is through a process of iteration using the multi line text methods detailed in "NSString UIKit Additions Reference". Extract the first few words from your string and start compositing these gradually until the " sizeWithFont:constrainedToSize:lineBreakMode:" returns a size which height is higher than that of a line with just 1 word.

0

精彩评论

暂无评论...
验证码 换一张
取 消