views:

52

answers:

2

Hi everyone, I'm struggling with line break in UILabel. I'm generating xml in vb.net and then parse it in iPhone application. xml contains text which initially contains html tags such as
, so I can and need to replace these tags with something to add a linebreak in iphone

How can I do it? I tried \n , \n\r, they a not working

Any help will be appreciated

Thank you

+1  A: 

\n should work. Make sure you set numberOfLines to 0, and lineBreakMode to something that suits you.

sha
I'm doing it, it's not working, label just shows "some text\nmore text"
Burjua
post a code please how you assign text to UILabel
sha
I don't assign static text, I'm getting it from xml parsing. Can it be the case? I have \n in text and it looks like objective-c just ignores it. I'm so confused about it because I can see that it works for other people. I'm miising somthing simple but can't find it.
Burjua
Check in the debugger what exactly you're assigning. Then compare it to the case if you assign the static text. Hopefully that would give you direction to fix the problem.
sha
Thanks for this advice, I found one interesting thing, I'm checking my string in debugger and I still can see 'some text\nmore text, but if I assign text manually like NSString *s = @"AAA\nBBB" it works and in this case in debugger \n looks thinner and paler. How can I replace my usual \n to thinner \n ?))
Burjua
Thinner and paler? Can you post a screenshot with it? Also can you post code that replaces <br> with \n in your XML text?
sha
Hi I solved the problem adding new line to xml like this: text = text.Replace("<br />", ControlChars.CrLf) this way didn't work:text = text.Replace("<br />", "\n"). About thinner and paler, I know it sounds stupid, so I made a couple screenshots, this is working: http://img638.imageshack.us/img638/9135/screenshot20100810at183.png and this is not: http://img227.imageshack.us/img227/9135/screenshot20100810at183.pngStill can't understand it can you explain it? anyway thank you for help))
Burjua
A: 

Refer this

Best of Luck.

Pugal Devan