Objective c 检测UITextView中的行数(iPhone 6 plus失败)

Objective c 检测UITextView中的行数(iPhone 6 plus失败),objective-c,uitextview,Objective C,Uitextview,我使用以下代码: numOfLine = (textView.contentSize.height - lineHeightFix ) / textView.font.lineHeight; - (void)viewDidLoad { [super viewDidLoad]; CGRect previousRect = CGRectZero; } - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange: (

我使用以下代码:

numOfLine = (textView.contentSize.height -   lineHeightFix ) / textView.font.lineHeight;
- (void)viewDidLoad
{
[super viewDidLoad];

CGRect previousRect = CGRectZero;

}



- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:  (NSRange)range replacementText:(NSString *)text
{
 if (currentRect.origin.y >= previousRect.origin.y)
{
  // Counts the lines    
}
previousRect = currentRect;
在iPhone4、5、5s、6中,这一行可以正常工作,但在iPhone6中,加上返回的行号不正确

我还尝试了以下代码:

float rows = (textView.contentSize.height - textView.textContainerInset.top - textView.textContainerInset.bottom) / textView.font.lineHeight;

但我将继续处理相同的问题。

我使用以下代码修复此问题:

numOfLine = (textView.contentSize.height -   lineHeightFix ) / textView.font.lineHeight;
- (void)viewDidLoad
{
[super viewDidLoad];

CGRect previousRect = CGRectZero;

}



- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:  (NSRange)range replacementText:(NSString *)text
{
 if (currentRect.origin.y >= previousRect.origin.y)
{
  // Counts the lines    
}
previousRect = currentRect;

你能给出每个字段的值和总结果吗?你能试着将整个ie:float rows=(float)(textView。。。