UITextView iOS 7的行数 [英] UITextView number of lines iOS 7

查看:111
本文介绍了UITextView iOS 7的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 6中,我使用此代码获取 UITextView 中的行数:

In iOS 6 I used this code to get the number of lines in the UITextView:

int numLines = textView.contentSize.height / textView.font.lineHeight;

但这在iOS 7中不起作用。如何获取UITextView的总行数在iOS 7中?

But this is not working in iOS 7. How do I get the total number of lines of the UITextView in iOS 7?

推荐答案

你可以使用这样的东西。这是低性能,但这是我现在可以想到的。

You can use something like this. It's low performance but this is what I could figure till now.

NSString *string=textView3.text;
NSArray *array=[string componentsSeparatedByString:@"\n"];
NSLog(@"%d",array.count);

这篇关于UITextView iOS 7的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆