UITextView just horizontal scrolling help

I have a UITextView, I want to show its text horizontally, my UITextView has a static width

[[UITextView alloc] initWithFrame:CGRectMake(0, 0, 161, 23)];

so when the length of the UITextView text is more than 23, I need a horizontal scroll of the UITextView, please help me ...

+3
source share
4 answers

put this code after initialization

[txt setContentOffset:CGPointMake(give_high_value_here_than_content, y)];

Good luck.

+1
source
- (void)viewDidLoad {
    // We restrict the horizontal scrolling here.
    self.textView.contentSize = self.textView.frame.size;
}

Implement this delegate method in text form.

Now that the characters entered are greater than 23, we set the size of the contents of the text view to a larger value so that horizontal scrolling is turned on automatically.

- (void) textViewDidChange:(UITextView *) tView {
    if (tView.text.length > 23) {
// Set some higher width of the text view content size.
        tView.contentSize = CGSizeMake(200.0f, tView.frame.size.height);
    }
}
+1
source

mscrollview.contentSize = CGSizeMake (180.30);
mscrollview.showsHorizontalScrollIndicator = YES;

Use two lines.

0
source

If you are using an interface builder, just check the property.

show horizontal scrolling.

by default this property does not include

0
source

All Articles