UITextView Interface Builder MultiLine Issue - iphone

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.

Related

How to set a UITextField to edit severals lines?

I have a UITextField that is 300px width and 270px height. When I want to edit it, the cursor goes automatically in the middle and I can only write on the middle line.
How can I set this UITextField to have severals lines and a cursor starting at the top-left ?
Simple answer, just use UITextView instead.
UITextfield is designed for single line only, If you want to enter multi line text than use UITextView instead and set its editable property to YES than it would behave like textfield!
[myTextView setEditable:YES];
Note: You can also set it via Interface Builder, select the "editable" box & It will be multiline by default.

How to change line in the UITextView with xib file

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...

Use line breaks of retrieved NSString

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.

iphone SDK: how to add a new line char to my uitextview programmatically?

Please help me adding a line break (\r\n) programatically to my UITextView.
If you get the text from the text view, create a mutable version of the text, then add just \n, the set the text view's text, it'll work. Don't put a carriage return and a linefeed both.

how to use paragraph text in uitableviewcell in cocoa-touch

I've been using uiLabels to put text in the cells of tableviews. I want to now use paragraph text that carriage returns to the next line instead of going out of the boundaries of the table cell. Would I do this by manipulating a uiLabel or would I use a different control all together like a text view.
Also is there any project examples out there that implement this?
Thanks,
Joe
Simplest way is to use a UILabel and set the number of lines in IB to > 1 then set the line break to "Word Wrap."
Another way is to use a UITextView, load the data and set it to 'disabled' so it can't be edited.
Finally, you can always go the UIWebView route and load it with formatted HTML, complete with line breaks, etc. Pretty heavy, but most flexible.
The simplest approach is to use a UILabel, probably. The only alternative would be to make a custom UIView subclass that draws the text directly, but that will give you marginal benefit.