progammingBeignner
progammingBeignner

Reputation: 936

make UitextView horizontally scrolling and not truncating the text.

I wish to make a horizontally scrollable uitextview in which a user can type text that is much longer than the width of the textview.

But currently, when i have implement a textfield, the text stops at the end of the textview, even when i continue to type and setting textContainer.maximumnumberoflines = 1.

I wish it to have the same vertical scrolling function where the height textview expands while users types more text onto the textview. But in my case, i want the width of textview to expand to accommodate words.

At the end of the long text, i wish to be able to scroll the textview horizontally to view the full text.

The current failed attempt by me looks like this. enter image description here

currently, the word stops at "hahahh", no matter how much i type, nothing changes.

Upvotes: 3

Views: 1243

Answers (2)

Chandrika
Chandrika

Reputation: 194

textContainer.maximumnumberoflines = 1 ----> This is not required (By default textField has scrolling property). You can initialize textField like this and it works. Here specify your textField frame, superView to which this textField has to be added, color and font.

UITextField *myTextField = [[UITextField alloc] initWithFrame:frame];
myTextField.font = giveFont;
myTextField.textColor = giveColor;
[superview addSubView:myTextField];

Upvotes: 3

Akhil Nair
Akhil Nair

Reputation: 444

You can use TextView instead of TextField. TextView is located just above the ScrollView in Object Library.

Check this out

Upvotes: 0

Related Questions