无法使文本视图滚动 - xcode 4.3

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10298600/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:04:30  来源:igfitidea点击:

cannot make a text view scroll - xcode 4.3

iosxcodeuiscrollviewscrolluitextview

提问by Sue Wright

I am using Xcode 4.3

我正在使用 Xcode 4.3

I have a single screen that has a text view UITextViewthat I wish to be able to scroll just vertically.

我有一个具有文本视图的屏幕,UITextView我希望能够垂直滚动。

I have added a scroll to the screen UIScrollviewand a UITextviewon top of that. I have created a new outlet called theScroller and in the viewcontroller.mfile added the line.

我在屏幕上添加了一个滚动条,UIScrollviewUITextview在其上添加了一个滚动条。我创建了一个名为 theScroller 的新插座,并在viewcontroller.m文件中添加了该行。

(void)viewdidLoad 
{
self.thescroller.contentSize=CGSizeMake(280.0,600.0);

However in most tutorials I have watched, they all add a line before this to set scroller to YES, but in Xcode 4.3 it wont let me. How do I turn the scroller on. what am I doing wrong.?

然而,在我看过的大多数教程中,他们都在此之前添加了一行以将滚动条设置为 YES,但在 Xcode 4.3 中它不会让我这样做。如何打开滚动条。我究竟做错了什么。?

I am a newbie at this so please keep things simple. thanks

我是新手,所以请保持简单。谢谢

回答by Domness

Firstly, is the content of the UITextViewlarger than the view dimensions for the UITextView? If it is larger, then it will scroll, if not, then it won't scroll.

首先,UITextViewUITextView的内容是否大于视图尺寸?如果它更大,那么它会滚动,如果不是,那么它不会滚动。

And with the UITextViewyou don't need an additional UIScrollViewfor it to scroll.

并且UITextView您不需要额外UIScrollView的滚动。

You've added the contentSizecode, however, the UITextView won't scroll if your text isn't larger than the normal view size. UITextView's automatically allow scroll if any text overflows from the size. Try adding a lot more text than will view, and see if it scrolls then.

您已经添加了contentSize代码,但是,如果您的文本不大于正常视图大小,则 UITextView 不会滚动。UITextView如果任何文本超出大小,则自动允许滚动。尝试添加比查看更多的文本,然后查看它是否会滚动。

回答by Suraj Pathak

I have exactly what you need in my public repo TextScroller. It supports normal right to left, left to right (Like LED) or floating type that floats like the music name in music player !

我在我的公共仓库 TextScroller 中有你需要的东西。它支持正常的从右到左,从左到右(Like LED)或像音乐播放器中的音乐名称一样浮动的浮动类型!