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
69
votes
22 answers

UITextView: Disable selection, allow links

I have a UITextView which displays an NSAttributedString. The textView's editable and selectable properties are both set to false. The attributedString contains a URL and I'd like to allow tapping the URL to open a browser. But interaction with the…
lukas
  • 2,300
  • 6
  • 28
  • 41
68
votes
12 answers

Adding a line break to a UITextView

I have a UITextView that takes an NSString with formatting stringWithUTF8String. It is getting its values from a database and I want the text in the database to be rendered with breaks within the text. I tried using \n to do this but it gets…
Mark Cicero
  • 737
  • 1
  • 6
  • 5
67
votes
6 answers

dismiss keyboard with a uiTextView

I am sure this is not that difficult, but I am having trouble finding info on how to dismiss a keyboard with the return/done key using a textview, not a textfield. here is what I have tried so far(which works with a textfield.) Thanks very much in…
user3708224
  • 1,229
  • 4
  • 19
  • 37
65
votes
14 answers

How do I size a UITextView to its content on iOS 7?

I've been using the accepted answer here for years. On iOS 7, the contentSize.height becomes the frame.height-8, regardless of text content. What's a working method to adjust the height on iOS 7?
Henrik Erlandsson
  • 3,797
  • 5
  • 43
  • 63
64
votes
6 answers

How to make a new line in UITextView in nib/storyboard?

I am trying to make a new line in Xcode 4.2 UITextView, and when I do alt+return, it goes to the next line, but does not show up when built and ran.
t3hcakeman
  • 2,289
  • 4
  • 25
  • 27
64
votes
8 answers

Add "padding" to a UITextView

as the title says i am trying to add padding-like behavior to a UITextView. The textview is generated when the view is pushed inside my navigation controller and the following code occurs: self.textView.layer.cornerRadius = 7; //pretty stuff is…
magtak
  • 986
  • 1
  • 9
  • 20
61
votes
8 answers

How to make UITextView detect links for website, mail and phone number

I have a UITextView object. The text in UIView has a phone number, mail link, a website link. I want to show them as links with following functionality. When someone taps on URL - Safari should open the the website. When someone taps on email link -…
AJ.
  • 1,443
  • 7
  • 19
  • 31
59
votes
4 answers

How to dynamically resize UITableViewCell height

I have the classical grouped UITableView with editable UITextViews inside every cell. This text views can be single or multi-lined, and I want the cell to increase its height as the user writes and the text starts a new line. My question is: do I…
araid
  • 677
  • 1
  • 9
  • 9
59
votes
17 answers

UITextView link detection in iOS 7

I have a UITextView which is managed via Interface Builder. As data detection I have "Links" checked. In iOS 6 everything is working fine and links are highlighted and are clickable. In iOS 7 though, all links remain just plain text. The editable…
Tobias
  • 1,577
  • 1
  • 13
  • 20
57
votes
9 answers

How to set margins (padding) in UITextView?

I have a UITextView for text editing. By default, it has a small margin around the text. I want to increase that margin by a few pixels. The contentInset property gives me margins, but it does not change the text "wrap width". The text is wrapped…
strawtarget
  • 1,059
  • 2
  • 9
  • 18
57
votes
17 answers

Large Text Being Cut Off in UITextView That is Inside UIScrollView

I'm having a serious problem that I just can't seem to fix and it's driving me insane for the last two days. I have searched far and wide and I can't find a solution, even though I have tried many. I have a UITextView inside a UIScrollView. I am…
sudo
  • 1,648
  • 1
  • 20
  • 22
55
votes
10 answers

UILabel auto resize on basis of text to be shown

I'm working on an application, in which I'm required to autoresize the text area on basis of text to be displayed. Firstly, I'm not sure for this either I should use UILabel (Logically is the best choice for displaying static text, which is in my…
Muhammad Uzair Arshad
  • 1,549
  • 1
  • 11
  • 9
55
votes
8 answers

How to set the border of UITextView to same as border color of UITextField

By default UITextField has a light gray color as its border color. I want to set my UITextView to have the same border color as the UITextField. I tried: myTextView.layer.borderColor = UIColor.lightGrayColor().CGColor //…
n179911
  • 19,547
  • 46
  • 120
  • 162
54
votes
7 answers

Create UITextRange from NSRange

I need to find the pixel-frame for different ranges in a textview. I'm using the - (CGRect)firstRectForRange:(UITextRange *)range; to do it. However I can't find out how to actually create a UITextRange. Basically this is what I'm looking for: -…
Johannes Lund
  • 1,897
  • 2
  • 19
  • 32
54
votes
11 answers

UITextView in iOS7 clips the last line of text string

UITextView in iOS7 has been really weird. As you type and are entering the last line of your UITextView, the scroll view doesn't scroll to the bottom like it should and it causes the text to be "clipped". I've tried setting it's clipsToBound…
ryan
  • 1,324
  • 2
  • 18
  • 29