cannot make a text view scroll - xcode 4.3

江枫思渺然 提交于 2019-12-13 00:28:50

问题


I am using Xcode 4.3

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

I have added a scroll to the screen UIScrollview and a UITextview on top of that. I have created a new outlet called theScroller and in the viewcontroller.m file added the line.

(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.?

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


回答1:


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

And with the UITextView you don't need an additional UIScrollView for it to scroll.

You've added the contentSize code, 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.




回答2:


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 !



来源:https://stackoverflow.com/questions/10298600/cannot-make-a-text-view-scroll-xcode-4-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!