views:

443

answers:

3

Hi,using Iphone sdk 3.1.2

I have a UITextView control with vertical and horizontal scrolling enabled. I want every line of text to display without wrapping so that the user can scroll horizontally to see it. The issue I have is that even with horizontal scroll enabled, the text wraps at the width of the iphone screen i.e.320 pixels.

How can I prevent wrapping?

Thanks

+1  A: 

Use sizeWithFont: from the NSString UIKit additions to get each line's width, then set your UITextView's contentSize property to be slightly wider than the width of the longest line.

jnic
A: 

It sounds like you want to prevent the text from wrapping. I believe you need to set the contentHorizontalAlignment property of the UITextField to UIControlContentHorizontalAlignmentLeft.

Edit-1: Disregard the above struck out only applies UITextField and has no relevance to UITextView.

TechZen
Hi, im using a UITextView, this does not have such a property
tech74
It's inherited from UIControl. Look in the documentation for UIControl. The class browser in Xcode is good for looking up inherited attributes and methods.
TechZen
UiTextView is not inherited from UiControl
tech74
Yes, sorry, my brain got stuck on UITextfield. Weird how that happens.
TechZen
A: 

I think you're stuck with putting a UITextfield in a scrollview.

TechZen