的UITextView只是水平滚动的帮助
我有一个UITextView,我要表现出水平的文字,我的UITextView有一个静态的宽度的UITextView只是水平滚动的帮助
[[UITextView alloc] initWithFrame:CGRectMake(0, 0, 161, 23)];
所以当的UITextView文本的长度大于23,我需要的UITextView水平滚动,请帮我...
mscrollview.contentSize = CGSizeMake(180,30);
mscrollview.showsHorizontalScrollIndicator = YES;
使用此2行。
把这段代码 初始化
[txt setContentOffset:CGPointMake(give_high_value_here_than_content, y)];
好运
如果使用界面生成器然后就检查属性后。
show horizontal scrolling.
默认情况下这个属性是不启用
不做任何事情 – SleepsOnNewspapers 2015-04-11 17:57:55
这只适用于滚动视图。不会更改文本的lineBreakMode – SleepsOnNewspapers 2015-04-11 18:25:15
- (void)viewDidLoad {
// We restrict the horizontal scrolling here.
self.textView.contentSize = self.textView.frame.size;
}
实现此文本视图委托方法。
现在当输入的字符大于23时,我们将文本视图的内容大小设置为更高的值,以便自动启用水平滚动。
- (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,但听起来没有工作 – juliet 2011-06-08 05:49:04
你必须处理的集寻呼厦门国际银行文件来实现,以及[TXT contentSize:cgrectmake()];和[txt setContentStretch:(CGRect)]; – NIKHIL 2011-06-08 09:27:50