Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextView how disable horizontal scrolling with content inset

Tags:

ios

uitextview

I created UITextview programmatically and I need set some left margin in text. I do this like:

myTextView.contentInset = UIEdgeInsetsMake(0.0, 5.0, 0.0, 0.0);

this working, but now I have horizontal scrolling.
I try set contentSize less than my text view frame (it equals 320 pt).

This

myTextView.contentSize = CGSizeMake(300.0, 39.0);

don't help.

I need to set left margin for text and only vertical scrolling.

like image 984
frankWhite Avatar asked Jan 23 '13 17:01

frankWhite


People also ask

How do I restrict horizontal scrolling?

To hide the horizontal scrollbar and prevent horizontal scrolling, use overflow-x: hidden: HTML. CSS.

How do I make a horizontal scroll into a div?

Set the overflow-y: hidden; and overflow-x: auto; that will automatically hide the vertical scroll bar and present only the horizontal scrollbar. The white-space: nowrap; property is used to wrap text in a single line. Here the scroll div will be horizontally scrollable.

How do I get rid of horizontal scrolling on mobile?

Check all of your elements on "Mobile" view, and remove any high margins to the left or to the right side of the element. The mobile horizontal scrolling has been caused by setting a high fixed / minimum width for an element. Set elements to "auto", or just reduce the width on mobile devices.


1 Answers

In stead of contentInset, use textContainerInset (iOS 7.0+)

myTextView.textContainerInset = UIEdgeInsetsMake(0.0, 5.0, 0.0, 0.0);
like image 57
thijsonline Avatar answered Oct 21 '22 03:10

thijsonline