Author Topic: UILabel sometimes goes beyond max lines value  (Read 8665 times)

CBYum

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 17
    • View Profile
UILabel sometimes goes beyond max lines value
« on: July 24, 2014, 05:36:53 AM »
We have a UILabel used in a popup box that we have fixed to 4 lines (variable width for mobiles). It can contain a variety of messages and going beyond 4 lines messes up our layout. We found a real case where it seems to put new lines right after a single character and this makes the label go to 5 lines instead of 4. I have reproduced it with random text if you play around with the amount of spaces it contains. Please see attachments to illustrate. Is this a setup problem or a problem with the wrapping logic?

Thanks


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel sometimes goes beyond max lines value
« Reply #1 on: July 25, 2014, 01:13:00 AM »
This is due to some very elusive issue that I've never been able to reproduce. If you can create a repro case for me, I would much appreciate it.

CBYum

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 17
    • View Profile
Re: UILabel sometimes goes beyond max lines value
« Reply #2 on: July 25, 2014, 02:44:56 AM »
Here is a singular case. Just include NGUI to the project and try this. I just set anchors on the label and didn't touch it in the scene view. I wrote lots of garble words. I then went back to the beginning of the text and moved right a bit and added a space and repeated that until the error occurred - didn't take long. Might be to do with the \n on the first line too, which I think is the only one. It seems to always wrap just one character to a new line and then add another new line.

Hope it helps

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel sometimes goes beyond max lines value
« Reply #3 on: July 26, 2014, 12:18:49 AM »
Unfortunately it doesn't. I don't see anything wrong in that scene, and me modifying the text exhibits no issues. Do you have step-by-step instructions?

CBYum

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 17
    • View Profile
Re: UILabel sometimes goes beyond max lines value
« Reply #4 on: July 28, 2014, 05:45:16 AM »
Ok
Once the example text box was created with the sizes in the example I added random test after a single line:

  1. TEST LINE
  2. weifjo fjeoijewfoij ewfoijewofij ewofijfj oiewfo ijwfe oijewf oijewofijewofi jew fjfje ofj

I then went to the beginning of the text after the "TEST LINE" and pressed right 2-4 times and then bit spacebar. I would check if the output shows 5 lines instead of 4. If it is ok I would continue this process until the bug happened. It usually didn't take long to get a case that had 5 lines. Also try adding more than one space each time too.

This is the actual text that failed in the example I sent:
  1. New Label
  2. we if jo ew fji  o ijwefoijo weofij oiewf oijow fejoiw efoijjoi jewofji oij ewfji ojioij oiwfe oijoiwfje oijwef oijoiiwefj oij ewfoij ofewj wef
And this results in the output in the attachment where there is a single "f" in the middle causing the problem.

I'm using Windows if that has any bearing on it. Could it be related to what is defined as a new line? A \n or a \n\r etc?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel sometimes goes beyond max lines value
« Reply #5 on: July 29, 2014, 03:04:25 AM »
I still can't reproduce this on 3.6.8. one thing to note as well... in your screenshot the width is 413. In the scene you attached, the width is 414 (or perhaps I changed it to that after moving the label, not sure). You're using some font I don't have, and I just see "Arial" in the scene you attached. I also use Windows here -- 8.1 to be exact.

Make sure that you're using a width/height that's dividable by 2. Your label is centered. If you don't do this, then you're effectively trying to align to half-pixels instead of to pixels.

CBYum

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 17
    • View Profile
Re: UILabel sometimes goes beyond max lines value
« Reply #6 on: July 29, 2014, 03:15:07 AM »
Ahh sorry, we are using 3.6.1 for our product. Will upgrade for the fix.