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

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

Now when I set the following:
[a addSubview:b];
the UIView a does something like:

Please help me out with this.
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