0

I am using Mac OS X Lion 10.7.5 and XCode Version 4.6.1 (4H512),

I have looked at these answers on stackoverflow to try to figure out my question -cannot make a text view scroll - xcode 4.3 -also posts that looked possible, when I searched on "scroll text in UITextView" within stackoverflow

Within Interface Builder I cannot figure out how to make information in a UiTextView object scroll within the iPhone simulator*. To resolve this challenge, I have made the most simple prototype project I can think of, just a view and one text view object on it, filling the text view object with a stream of text simply typed in via interface builder. For this most basic sample I'm using to sort out my problem, I have not done anything programatic. (Please note that I am aware of StoryBoards and have begun working through a book to learn to use them, but I would like to finish my first prototype app using what I’ve already learned and fully complete one project before I move onto my next project using StoryBoards.)

When I run this in the iPhone simulator, I see the sample information in my text view object come up. As I expected not all the information displays, due to my sizing the box a little too small on purpose. But I cannot flick or arrow down, or in any other way view the rest of the text information within the simulator. Nor do I see scrolling bars anywhere on the view. The information is just frozen in/on the view.

Inspector Settings Identity Inspector "Accessibility" Tested both with Enabled checked and not checked Use Auto Layout is NOT checked

Attributes Inspector Behavior Editable box not checked Scroll View Area Checked ‘show horizontal scrollers, shows vertical scrollers and also scrolling enabled” The rest of the scrollers box are not checked Bounces is checked Zoom min and max are both 1 Touch all boxes checked- bounces zoom, delays content touches, cancellable content touches

View mode is ‘scale to fill”
Interaction ‘multiple touch’ is checked

Drawing checked opaque, clears graphics context, clip subviews, and autoresize subviews. Only ‘hidden’ is not checked

Size Inspector

I played around with the ‘scrolling insets’ boxes changing them from the default (I think it was 0 or 1), just to see if I noticed anything. I think maybe that I see some shadowy marker type lines in Interface builder in the area where I might expect a scroll bar when I make these changes, but no change in appearance within the simulator.

  • I cannot figure out why my actual iPhone device with everything up to date, is now not working as a test device, but I believe that is a separate challenge
Community
  • 1
  • 1
LaurelS
  • 492
  • 2
  • 8
  • 22

2 Answers2

0

how about wrapping you uitextfield in a uiscrollview. Make the scroll view the dimensions you currently are setting the uitextfield to, then allow your uitextfield to scale to the size of the text.

Augie
  • 1,341
  • 1
  • 11
  • 18
  • Thank you. I will see if I can figure out how to do that. – LaurelS Jun 18 '13 at 18:31
  • So I went and dragged a uiscrollview object onto my view, and sized it to be smaller than the amount of test information I typed in, by simply dragging the corners in Interface Builder. I dragged the UItextView object on top of that, but I don't see scroll bars when I run it. So I think I don't know how to do this part you said... " Make the scroll view the dimensions you currently are setting the uitextfield to, then allow your uitextfield to scale to the size of the text." Is that something I do with an inspector? Or is that something I do programatically? – LaurelS Jun 18 '13 at 18:37
  • It would be interesting, and educational, to learn how to do it this way. But I still have the feeling I've gotten scrolling behavior in UITextField objects in the past, using the simpler straightforward way. I keep thinking I'm doing something wrong with an inspector check box or something similar. – LaurelS Jun 18 '13 at 18:39
  • your uitextview dimensions need to be set larger than your uiscrollview. I just realized uitextview doesn't scale to fit text. you can resize your text view with code like this. http://stackoverflow.com/questions/50467/how-do-i-size-a-uitextview-to-its-content Note some of this has to be done in your view controller or a subclass of uitextview, and not in interface builder if you want users to add text. – Augie Jun 18 '13 at 18:43
  • Thanks. I forgot to say this is an informational app. This particular information will be non-editable. I will follow up that link. – LaurelS Jun 18 '13 at 21:31
  • BTW I did try this, because it was an interesting idea. Thanks Augie. But I knew from the apple documentation that the textView object should scroll and wanted to get that to work. – LaurelS Jun 24 '13 at 17:03
0

This is one of those questions that solved itself eventually. After twice creating the most basic app, with no programmatic bits just interface builder and a textView object with all the defaults the scrolling worked. The only reason I can think of that it might not have scrolled as expected the first time through may have had to do with placement of the textView object on the view. I wonder if it overlapped the bottom of the view and maybe that messes something up.

Just one of those situations where I had to keep plugging away, trying what seemed like the same thing repeatedly,set in the Inspectors, and suddenly, like magic, it worked. Except no magic involved.

LaurelS
  • 492
  • 2
  • 8
  • 22
  • I think maybe the possible overlap relates to this answer on someone else's older post. http://stackoverflow.com/questions/10298600/cannot-make-a-text-view-scroll-xcode-4-3?rq=1 – LaurelS Jun 24 '13 at 17:05