I use UITextView to hold some infomation, and I have edited the text in the .xib file. The line will be changed when the current line has no space. The problem is that I don`t not how to change line when I want to. Look at the pic below:
I have try to use "\n" or "\\n", but it is displayed as text. I want to know how can I change line in the .xib file?
this should work...
textView.text=#"Ankit \r Srivastava";
this should give you both the words in different rows...
Related
Under certain circumstances, UILabel seems to bring an extra word to new line even when there is enough space for it, for example,
If one more word is appended,
Even if I force the width of the label to become something like below, it still moves the word consists of "c"s to the next line,
I've tried twisting the configuration of the UILabel, but seems it behaves the same unless I set the line breaking mode to character wrap, below is the configuration for the above cases,
And the constraints (in the first two cases, the trailing ),
Is there any reason for this particular behaviour and can I fix this? It looks weird in this way leaving that space emptied.
this is the default behavior since iOS 11, to fix orphaned words. No way to shut it off
to fix it
use the text as attributed text
or
use UItextview and turn of the scroll, edit option
or
use the custom label here
Get each line of text in a UILabel
You should set the line break to character wrap, because the letters after the space will be recognized as a word.
Hey I know this is late but I just figured out that you can cheat the system by adding a bunch of spaces at the end of the text.
If text of UILable may be changed, then it's still possible to use quick-dirty hack with "\n" - new line symbol.
Text "Aaaaaaaaaaaaaa bbb cccccccccc\ndddddd" will force UILabel to display:
Aaaaaaaaaaaaaa bbb cccccccccc
ddddddd
In Interface Builder new line can be inputted with Ctrl + Enter
If u use wordWrap, it tries to keep words in full form, as a result of this, it goes to next line. If you use character wrap, it will break on characters, and push the chars onto next line.
For Example:-
My name is ABCXXXX and I (have space here)
love myself.
Solution:-
Use NSMutableAttributedText and write love\n. It will make the "love" be in the space myself in the next line.
I just use the custom Uilabel in a tableview which i have given a some text lines from my sqlite table.I set label.numberoflines=0;It wraps but second line appear one space before first line. How to get the second line in the same x position which the first line is.
Make sure that your UILabel is left aligned:
yourLabel.textAlignment = UITextAlignmentLeft;
or do it in ib if you're using it.
I am using a UITextView in Interface Builder and have typed a hunk of text into it and there are lots of lines breaks in it, blank lines. I did this by typing into it and alt-returning to get a new line.
However when built and run on my device none of these line breaks are seen. Any tips? Anyone heard of this?
Thanks.
This works for me:
In the header file:
IBOutlet UITextView * textview;
In the implementation file:
textview.text = #"First line\nSecond line\n\nThere is a blank line above\n\tTabbed line";
Don't forget to link the UITextView with the element in the Interface Builder.
Write the text into a text file. And use a line of code to load the file's content into your UITextView. Much easier if you have a lot of text to input.
I have a UILabel with a dynamic string as the text property. If I always want the first word to be underlined, do I need to separate labels and then try to line them up correctly? Or could I subclass UILabel to have it do this?
Use a UIWebView and render the text as HTML.
I ended up using the textRectForBounds:limitedToNumberOfLines: to find the dynamic start point of the word (minus some x coordinate pixels), and then took away the first letter of the uilabel with stringByReplacingCharactersInRange:withString:, and then added another uilabel with the beginning letter of the original label, just with different font.
I retrieve an NSString from a Property list and display it in a UILabel. The NSString already includes \n s, however the UILabel just displays them as text. How can I tell the UILabel to actually use the \n s as line breaks?
Everything you type into a plist in the plist editor is interpreted as plain text. Try it... put a ' into a field and right click -> view as "plain text" and you'll see it substitutes it for '. Therefore you can't put \n into a plist because it thinks you're just typing text and will treat it as such. Instead of putting \n into your plist use Alt+Enter to get your newline. If you view this as a text file now you'll see \ns printed and new lines acctually shown in the text file.
Now when you output it it won't display \n it will just give it a new line.
Plus, as has been mentioned UITextField is only one line anyway and you probably would benefit from using UITextView.
Well, first, you are going to need a string that you can modify. To accomplish that, you can simply do:
NSMutableString* correctedPath = [path mutableCopy];
At that point, you can use -insertString:atIndex: to insert any characters you need.
You're using the wrong class here.
UITextField doesn't (for all that I know) support multi-line input. For that, you will need a UITextView (it has editing enabled by default). It should interpret \n's without any problems. It also has a lineBreakMode property, if you want to make use of that.