0

I am developing a UI for my application and need some content in UIScrollView in the middle of the page. I have a UIView (a) set in the main view. Something like this

enter image description here

I have another UIView in the same xib with uiscrollview in that UIView(b) like:

enter image description here

Now when I set the following:

[a addSubview:b];

the UIView a does something like:

enter image description here

Please help me out with this.

Matt
  • 74,352
  • 26
  • 153
  • 180
Tu Ch
  • 133
  • 1
  • 11

1 Answers1

1

If you want it to scroll to your second button, you need to set your scroll view's contentSize in code. Take a look at the answer to this question: How I auto size a UIScrollView to fit the content

Community
  • 1
  • 1
Matt Long
  • 24,438
  • 4
  • 73
  • 99
  • The scrollview is big enough...the uibutton is like on 220 while size of scrollview is 250..i dont want to see the uibutton down there i want to scroll to it...also keep in mind that uiscrollview is in view b which is 200 – Tu Ch Jun 06 '12 at 16:15
  • A couple of points. Your scrollview's contentSize must be set to be bigger than your scrollview bounds. If you don't want to see the button, you have to clip the subviews of your scrollview. Look for the "Clip Subviews" checkbox on your scrollview in Interface Builder. Make sure that is checked and you won't see the button until you scroll to it (assuming your contentSize is set correctly). – Matt Long Jun 06 '12 at 16:22
  • thanks matt..had always wondered what clip to subview was for – Tu Ch Jun 06 '12 at 21:55