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
130
votes
11 answers

Can I change the color of auto detected links on UITextView?

I had a UITextView that detects phone numbers and links, but this overrides my fontColor and change it to blueColor. Is there a way to format the color of auto detected links, or should I try a manual version of this function?
Leandro Alves
  • 2,190
  • 3
  • 19
  • 24
129
votes
12 answers

Detecting taps on attributed text in a UITextView in iOS

I have a UITextView which displays an NSAttributedString. This string contains words that I'd like to make tappable, such that when they are tapped I get called back so that I can perform an action. I realise that UITextView can detect taps on a URL…
tarmes
  • 15,366
  • 10
  • 53
  • 87
119
votes
16 answers

Swift: Display HTML data in a label or textView

I have some HTML data, which contains headings, paragraphs , images and lists tags. Is there a way to display this data in one UITextView or UILabel?
Talha Ahmad Khan
  • 3,416
  • 5
  • 23
  • 38
113
votes
33 answers

How disable Copy, Cut, Select, Select All in UITextView

The UITextView's Copy, Cut, Select, Select All functionality is shown by default when I press down on the screen. But, in my project the UITextField is only read only. I do not require this functionality. Please tell me how to disable this feature.
Aishwarya
  • 1,587
  • 3
  • 14
  • 9
112
votes
23 answers

how to make UITextView height dynamic according to text length?

As you can see in this image the UITextView changes it's height according to the text length, I want to make it adjust it's height according to the text length. *I saw other questions, but solutions there didn't work for me
DeyaEldeen
  • 10,847
  • 10
  • 42
  • 75
112
votes
9 answers

How to intercept click on link in UITextView?

Is it possible to perform custom action when user touch autodetected phone link in UITextView. Please do not advice to use UIWebView instead. And please don't just repeat text from apple classes reference - certainly I've already read it. Thanks.
Vladimir
  • 7,670
  • 8
  • 28
  • 42
102
votes
37 answers

How do I force a UITextView to scroll to the top every time I change the text?

OK, I'm having some problem with the UITextView. Here's the issue: I add some text to a UITextView. The user then double clicks to select something. I then change the text in the UITextView (programatically as above) and the UITextView scrolls to…
Sam Stewart
  • 1,470
  • 3
  • 14
  • 14
91
votes
6 answers

IOS - remove ALL padding from UITextView

There are many great examples on SO to remove the left padding of a UITextView. How to lose margin/padding in UITextView? However, I need to remove the right padding too. I have tried... [tv setContentInset: UIEdgeInsetsMake(-4,-8,-8,-X)];//where X…
mattyd
  • 1,643
  • 2
  • 17
  • 26
89
votes
11 answers

Display html text in uitextview

How can I display HTML text in textview? For example, string <h1>Krupal testing <span style="font-weight: bold;">Customer WYWO</span></h1> Suppose text is bold so it display in textview as bold string but I want display…
milanjansari
  • 1,529
  • 2
  • 21
  • 33
87
votes
18 answers

Limit number of characters in uitextview

I am giving a text view to tweet some string . I am applying the following method to restrict the number of characters to 140 in length. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString…
harshalb
  • 6,012
  • 13
  • 56
  • 92
82
votes
11 answers

Limit the number of lines for UITextview

I was wondering how to limit the amount of LINES (not characters as asked in other questions) a user can enter when editing a UITextField. Ideally, I would like to limit the input to max. 10 lines. Where would I need to start? Do I do this with a…
n.evermind
  • 11,944
  • 19
  • 78
  • 122
79
votes
22 answers

UITextView text content doesn't start from the top

I have a long text coming from my JSON file but when I click the link from my UITableViewCell to go to my UIViewController page, the UITextView text loads the string content but it does not show the content from the beginning and I have to scroll up…
Ornilo
  • 791
  • 1
  • 5
  • 4
78
votes
9 answers

iOS7 UITextView contentsize.height alternative

I'm porting one of apps from iOS 6.1 to iOS 7. I'm using a layout where there's a UITextView that has a fix width, but it's height is based on its contentsize. For iOS 6.1 checking the contentsize.height and setting it as the textview's frame height…
Zoltan Varadi
  • 2,468
  • 2
  • 34
  • 51
75
votes
19 answers

Center text vertically in a UITextView

I want to center the text vertically inside a big UITextView that fills the whole screen - so that when there's little of text, say a couple of words, it is centered by height. It's not a question about centering the text (a property that can be…
Sergey Grischyov
  • 11,995
  • 20
  • 81
  • 120
73
votes
11 answers

Cursor not showing up in UITextView

Can anyone think of a reason that the blinking cursor would not show up in a UITextView? I have a custom control that is just a subclass of UIView and it has a UITextView in it, but the cursor doesn't appear when it gets focus. The keyboard appears,…
SeanT
  • 1,741
  • 1
  • 16
  • 24