1

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

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
Sue Wright
  • 21
  • 1
  • 4
  • Just be sure that what you want to scroll. You want to scroll whole textview or text inside the textview? Try this if you want to scroll whole textview. self.thescroller.scrollingEnabled = YES; – iMash Apr 24 '12 at 13:26

2 Answers2

4

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.

Domness
  • 7,585
  • 8
  • 40
  • 50
  • +1 For a simple and correct answer, this is one of those things that is actually as simple as it should be. – Mick MacCallum Apr 24 '12 at 16:49
  • Ok. I have removed the IUscrollview and re- added the IUtextview. Below are myviewcontroller. m and .h files. It still wont scroll. Am I missing something. – Sue Wright Apr 24 '12 at 18:53
  • It still wont scroll. Am I missing something. viewcontroller.h #import interface ViewController : UIViewController @property (strong, nonatomic) IBOutlet UITextView *Textscroller; end viewcontroller.m #import "ViewController.h" interface ViewController () end implementation ViewController synthesize Textscroller; - (void)viewDidLoad{ self.Textscroller.scrollEnabled = YES; self.Textscroller.showsVerticalScrollIndicator =YES; self.Textscroller.contentSize=CGSizeMake(280.0, 600.0); [super viewDidLoad]; – Sue Wright Apr 24 '12 at 19:03
  • Thank you. it will now scroll if i use the up and down arrows on the keyboard. Hoever still cannot see the vertical slider indicator on the on the simulator despite adding the command. This is soooo frustrating – Sue Wright Apr 25 '12 at 08:15
  • Having a blonde female moment - all sorted. Thank you for your patience – Sue Wright Apr 25 '12 at 08:29
0

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 !

Suraj Pathak
  • 910
  • 8
  • 9