iOS - how do I make a text field taller than 1 line? - ios

I am making my first text field, and I am looking for more of a text area that the person can fill out. Xcode disables for me the ability to extend it to more than one line. Is it possible? If so, how do I do that?
Thanks!

You want a UITextView, which is an editable field that can accomodate more than one line of text.

A multiline UITextField is implemented by the UITextView and making sure its editable property is set to YES.
The UITextView class implements the behavior for a scrollable, multiline text region.

Related

How to change UILabel text with user typing message

Is it possible to change the UILabel text by user interaction? Or is it necessary to do it with a UITextField element?
Can you tell me the way of doing it?
I don't think that it's possible to change the UILabel text by user interaction.
I would use a UITextField with no borders to make it look like a UILabel. You can do this using the Attributes Inspector in the storyboard.
UILabel is inherently not editable, from the class reference:
The UILabel class implements a read-only text view.
You would have to use a UITextField or a UITextView - UITextView being more like a UILabel than a UITextField.
From the UITextView class reference:
The UITextView class implements the behavior for a scrollable, multiline text region. The class supports the display of text using custom style information and also supports text editing. You typically use a text view to display multiple lines of text, such as when displaying the body of a large text document.

Which component use for displaying a paragraph of text in iOS?

I want to show a paragraph of text. I have tried UILabel but this makes the text vertically aligned: it does not start from top. If I use UITextView and disable the properties selectable and editable it behaves like UILabel. Which component should I use?
You can use UILabel to TextView with NSAttributtedString.
Also you can also set your ULLabel or textview text attribute from storyboard .

How do I have padding at the bottom of my UITextView like in Mail.app so the text isn't scrunched?

In Mail.app, if I go to create a new message and type all the way so the text is at the last line of the UITextView there is still a decent amount of space between the last line of text and the keyboard if you scroll down. But you can't type here. It's just nice padding so you can read it without it being scrunched against the keyboard, and if you select the text, the selection handles don't extend under the keyboard.
My question is, how do I mimic this with a traditional UITextView?
I think you can do this by setting the contentInset property of your UITextView:
myTextView.contentInset = UIEdgeInsetsMake(-4,-8,0,0);
btw... the values above are not specific to your situation. You will want to adjust these to get the inset you are looking for.

How to resize the UITextField in IOS

- How to increase the height of the text field in order to accommodate multiple lines, as the text field grows accordingly.
- I want something like multiple line attribute in android.
UITextField not supporting multiple lines text place UITextView in the place of UITextField.
Look at UITextView and not a UITextField.
Use HPGrowingTextView for iOS for multiple lines textview

add button in textview -xcode

How can I add a button in textview? for example..
textView.text=#"text here\n\n text also here\n\n text here aswell";
How can I add a button after each "\n\n" or along the text?
You can create a object of UIButton and add it as subview to yout textview.
You need to preset the frame of the button So the text must be statis and you must know the position of the button in advance.
so your \n\n creates a paragraphs
You can do it without static text just split your text in separate textviews by \n\n, add them to your scrollview. You have to measure your text paragraphs height to set the right frame for textviews and leave gaps for buttons. I would rather use tableview so you dont have to worry about that. Add buttons in between, it is doable.
you may reconsider adding buttons along the text this way (you can but it is really convoluted way of doing things), use webview for that as already stated here by others

Resources