Questions tagged [uitextview]

The UITextView class implements the behavior for a scrollable, multiline text region in iOS. The class supports the display of text using a custom font, color, and alignment 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.

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.

Before iOS 6 () the text could only be styled as a whole, since then the view supports finer grained control of the text style through the .attributedText property.

References:

UITextView Class Reference

5806 questions
754
votes
63 answers

Placeholder in UITextView

My application uses an UITextView. Now I want the UITextView to have a placeholder similar to the one you can set for an UITextField. How to do this?
user142019
563
votes
24 answers

How to lose margin/padding in UITextView

I have a UITextView in my iOS application, which displays a large amount of text. I am then paging this text by using the offset margin parameter of the UITextView. My problem is that the padding of the UITextView is confusing my calculations as it…
sniurkst
  • 7,212
  • 5
  • 30
  • 30
561
votes
41 answers

How do I size a UITextView to its content?

Is there a good way to adjust the size of a UITextView to conform to its content? Say for instance I have a UITextView that contains one line of text: "Hello world" I then add another line of text: "Goodbye world" Is there a good way in Cocoa…
drewh
  • 10,077
  • 7
  • 34
  • 43
480
votes
26 answers

Multiple lines of text in UILabel

Is there a way to have multiple lines of text in UILabel like in the UITextView or should I use the second one instead?
Ilya Suzdalnitski
  • 52,598
  • 51
  • 134
  • 168
403
votes
44 answers

Add placeholder text inside UITextView in Swift?

How can I add a placeholder in a UITextView, similar to the one you can set for UITextField, in Swift?
StevenZ
  • 6,983
  • 5
  • 16
  • 18
399
votes
34 answers

How to dismiss keyboard for UITextView with return key?

In IB's library, the introduction tells us that when the return key is pressed, the keyboard for UITextView will disappear. But actually the return key can only act as '\n'. I can add a button and use [txtView resignFirstResponder] to hide the…
Chilly Zhong
  • 16,763
  • 23
  • 77
  • 103
354
votes
15 answers

After upgrading to Xcode 11.2 from Xcode 11.1, app crashes due to _UITextLayoutView

After upgrading to Xcode 11.2 from Xcode 11.1 my app crashes: *** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named _UITextLayoutView because no class named…
Sudhakar Tharigoppula
  • 2,857
  • 3
  • 16
  • 17
290
votes
11 answers

How to create a multiline UITextfield?

I am developing an application where user has to write some information. For this purpose I need a UITextField which is multi-line (in general UITextField is a single line). As I'm Googling I find a answer of using UITextView instead of UITextfield…
raaz
  • 12,410
  • 22
  • 64
  • 81
248
votes
16 answers

Change UITextField and UITextView Cursor / Caret Color

I'm wondering about changing the color of the cursor / caret in a UITextField (And UITextView if its the same answer) in iOS. I've seen answers for OSX development, but nothing for iOS. Is this even possible?
RileyE
  • 10,874
  • 13
  • 63
  • 106
234
votes
23 answers

How can I make a clickable link in an NSAttributedString?

It's trivial to make hyperlinks clickable in a UITextView. You just set the "detect links" checkbox on the view in IB, and it detects HTTP links and turns them into hyperlinks. However, that still means that what the user sees is the "raw" link.…
Duncan C
  • 128,072
  • 22
  • 173
  • 272
183
votes
17 answers

UITextView that expands to text using auto layout

I have a view that is laid out completely using auto layout programmatically. I have a UITextView in the middle of the view with items above and below it. Everything works fine, but I want to be able to expand UITextView as text is added. This…
tharris
  • 2,192
  • 2
  • 13
  • 14
173
votes
20 answers

How to style UITextview to like Rounded Rect text field?

I am using a text view as a comment composer. In the properties inspector I can't find anything like a border style property so that I can make use a rounded rect, something like UITextField. So, the question is: How can I style a UITextView like a…
harshalb
  • 6,012
  • 13
  • 56
  • 92
160
votes
5 answers

Getting and Setting Cursor Position of UITextField and UITextView in Swift

I've been experimenting with UITextField and how to work with it's cursor position. I've found a number of relation Objective-C answers, as in Getting the cursor position of UITextField in ios Control cursor position in UITextField UITextField get…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
146
votes
13 answers

UITextView style is being reset after setting text property

I have UITextView *_masterText and after call method setText property font is being reset. It's happening after I change sdk 7. _masterText is IBOutlet, global and properties are set in storyboard. It's only me or this is general SDK…
Błażej
  • 3,617
  • 7
  • 35
  • 62
143
votes
19 answers

How can I change the color of a part of a TextView?

text = text + CepVizyon.getPhoneCode() + "\n\n" + getText(R.string.currentversion) + CepVizyon.getLicenseText(); activationText.setText(text); myTextView.setText(text); I want to change color for CepVizyon.getPhoneCode()'s…
atasoyh
  • 3,045
  • 6
  • 31
  • 57
1
2 3
99 100