UITextView只是横向滚动帮助 [英] UITextView just horizontal scrolling help

查看:356
本文介绍了UITextView只是横向滚动帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITextView,我希望在水平显示它的'文本,我的UITextView有一个静态宽度

I have a UITextView , i want show its' text in horizontal, my UITextView has a static width

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

所以当UITextView文本的长度大于23时,我需要UITextView水平滚动,请帮帮我...

so when the length of UITextView's text is greater than 23, i need UITextView horizontal scrolling , please help me...

推荐答案

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

实现此文本视图委托方法。

Implement this text view delegate method.

现在输入的字符大于23时,我们将文本视图的内容大小设置为更高的值,以便自动启用水平滚动。

Now when the characters entered becomes greater than 23, we set the content size of the text view to a higher value so that horizontal scrolling gets enabled 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);
    }
}

这篇关于UITextView只是横向滚动帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆