1

I'm working on embedding a UIScrollView in UIContainerView so that I can have several text fields.

I tried implementing the solution from this SO answer, but haven't been successful.

Both view controllers are set to be freeform as described in the answer above, and both are set to have a height of 920. Below is what my storyboard looks like:

storyboard

But below is what this looks like when I run the app:

simulator

I can't scroll down past the first 4 text fields, even though the scroll view embedded in my container view has 8 text fields. Anyone know how to make this work? Thanks!

EDIT

I have it partially working, this video gave some good pointers. What I have is a container view embedded inside of a scroll view. In the view held by the container, I've set 'simulated size' to be freeform. I made the width 320, and the height 1000, so that I have enough room for all the text fields.

What I'm having difficulty with at the moment is that when I scroll down, I can only scroll down to the sixth text field, when there are eight (picture below). Anyone have any suggestions on how to fix this?

scrolling without all text fields

Community
  • 1
  • 1
narner
  • 2,908
  • 3
  • 26
  • 63
  • did you set delegate for scrolview? is your container is within scrollview? – Noor Sep 21 '14 at 14:48
  • @N.A, it looks like my container wasn't embedded in a scrollview. I fixed that, but still no change in behavior. – narner Sep 21 '14 at 14:56

2 Answers2

2

Do like this

 - (void)viewDidAppear:(BOOL)animated
    {
        [super viewDidAppear:animated];
        yourScrollView.contentSize=CGSizeMake(320,1300);
    }
Noor
  • 2,071
  • 19
  • 28
  • Thanks @N.A, this helped; I realized that I had set the Y value of CGSizeMake incorrectly. I have some more work to do with setting this up with AutoLayout, but this solved my problem for the moment! – narner Sep 23 '14 at 14:53
0

It would be helpful to see the configuration and your Autolayout constraints. For similar cases, I usually use a configuration as described in this video:

http://www.youtube.com/watch?v=4oCWxHLBQ-A

CarlosGz
  • 396
  • 2
  • 6
  • Hi Carlos, I actually had auto-layout disabled for this view controller. I'll check out the video; do you know of any other code examples I could take a look at? – narner Sep 23 '14 at 02:52
  • I had actually set the Y value of ` [scroller setContentSize:CGSizeMake(320, 2500)];`to be smaller then the container view. So, it's almost working! Just not with auto-layout. – narner Sep 23 '14 at 03:22
  • On the other hand, instead of a Container you can use a static TableView and it automatically will scroll on the screen when you tap on any TextField, and you can also select on the interface builder keyboard "dismiss on drag" for show and hide the keyboard automatically. – CarlosGz Sep 23 '14 at 12:48