If you are using iOS 3, you need to use the leading
property:
int numLines = txtview.contentSize.height / txtview.font.leading;
If you are using iOS 4, you need to use the lineHeight
property:
int numLines = txtview.contentSize.height / txtview.font.lineHeight;
And, as @thomas pointed out, be careful of rounding if you need an exact result.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…