1

I had a previous post where I asked if there is any other method than this :

var maxNumberOfLines: CGFloat = 3
var numLines = textView.contentSize.height/textView.font.lineHeight
if (numLines > maxNumberOfLines)
   {
   textView.text = (textView.text as NSString).substringToIndex((textView.text as NSString).length - 1)
   }    

for limiting user's input.
I ask this, because I want to know what I should change in order to block it from passing the second line.
With the method above, I can still press the return key, it goes down to the third line, and if I try to type anything, it goes back up on the second.

  • Just my 2¢: restricting user input by number of lines feels wrong - different lengths of text on different devices. – Jakub Vano Jun 03 '15 at 08:20
  • Hei mate. I took care of that by increasing or decreasing font size depending on used device. I know it feels wrong, but it's the task I've got and I have to make it. – razvanifteme Jun 03 '15 at 08:37
  • You might want take a look here http://stackoverflow.com/questions/411398/limiting-text-in-a-uitextview – Jakub Vano Jun 03 '15 at 08:46
  • hi, did you find any solution for this problem ?? i faced the same problem two, and no answer could help me :( @razvanifteme – Rawan Sep 27 '15 at 10:03

0 Answers0