如何在UITextView上强制水平滚动? [英] How to enforce horizontal scrolling on UITextView?

查看:79
本文介绍了如何在UITextView上强制水平滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITextView,我只希望它只能水平滚动。

I have a UITextView and I would like to only allow it to be scrollable horizontally only.

基本上,当UITextView换行时,我希望用户必须水平滚动以查看其余内容。

Basically when the UITextView word-wraps I want the user to have to scroll horizontally to be able to view the rest of the contents.

推荐答案

您可以将文本视图的内容大小设置为视图的高度。只要确保内容的宽度超过textView框架的宽度,否则它就不会滚动。

You can set the content size of the text view to the height of the view. Just make sure the width of the content extends past the width of the textView's frame or else it won't scroll.

// UITextView* myTextView: gets declared somewhere...

// The text view (subclass of a UIScrollView) won't go past its content size
[myTextView setContentSize:CGSizeMake(width, myTextView.frame.size.height)];

// Just in case, if you don't want your user bouncing the view up/down
[myTextView setAlwaysBounceVertical:NO];

我希望这就是您想要的。

I hope that's what you were looking for.

这篇关于如何在UITextView上强制水平滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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