Question

Can someone please guide me to a tutorial , on how to implement a vertical scrolling view on my iOS app?

I can't believe that the last 2 days , I can't find a single working example on just a vertical scrolling view. All the tutorials are about horizontal scrolling, zooming etc etc.

What I am looking for would be something like this tutorial http://www.edumobile.org/iphone/iphone-programming-tutorials/scrollview-example-in-iphone-2/, which shows how to make a uiscrollView and add objects to it, from the Builder and not programmatically. The only flaw I found was , that when trying to add a map down in the scrolling area, the map would appear up and not in the position I placed it. Maybe any ideas on that too?

Anything in mind?

Was it helpful?

Solution

So you want to create a scroll view in xib.

  1. Add a scroll view to the nib file
  2. set its size to to whatever you want

    enter image description here

  3. Add your controls (Buttons,labels..)

    enter image description here

  4. Add it as a sub view of main view

    enter image description here

  5. Finally create a property of scroll view and in viewDidLoad set the content size of the scroll view

     self.scrollView.contentSize =CGSizeMake(320, 700);
    

OTHER TIPS

It simple, same as horizontal scroll view. Add a scrollview in a view hierarchy,

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:scrollView];

Now to make scroll view scrollable, set its scrollview content size greater than its bound.

[scrollView setContentSize:CGSizeMake(scrollView.bounds.size.width, scrollView.bounds.size.height*3)];

Now it can scroll three time the height of scrollView.

I've struggled with this simple issue for a full day. There are most likely benefits to a more sophisticated approach, but unchecking autolayout solved my issue.

For the quick fix, I believe this is the best approach and will save you a HUGE headache.

Just change the content size of your scrollview.Let's assume you are creating a UIScrollView with the following frame

scl=[[UIScrollView  alloc]initWithFrame:CGRectMake(0, 0, 620, 172)];

Now call the content size property of your scroll view,like i have shown below .

[scl setContentSize:CGSizeMake(700, 172)];

Now add the scroll view on a view / View Controller etc and check it .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top