How do I make a scrollable view in iOS?
I want to create a Settings page for my application and since there are a lot of them, the phone screen is not enough to show.
So I need the user to be able to scroll down the view to see more options until the last one. I know I should be using scrollview, but I don't know how.
All the tutorials I've found are about full screen scrolling, zooming, left to right scrolling, but nothing about how you can create simple page up and down scrolling.
How exactly do I do it? Am I making a lot of .nib files and connecting them somehow? Am I making a large .nib file?
Can anyone lead me to a tutorial?
Use the ContentSize
property UIScrollView
to scroll to any area you want. those.
take UIScrollView
add it on UIView
with iPhone height. those. Max. 460.0 Thus, the frame ScrollView
will be the maximum (0,0,320,0,460.0).
Now after adidng ScrollView
to View
set the property ContentSize
to scrollable area.
[self.mainScrollView setContentSize:CGSizeMake(self.mainScrollView.frame.size.width, 1000.0)];
source to share
UIScrollView *mainScroll = [[[UIScrollView alloc]initWithFrame:CGRectMake(x,y,w,h)]autorelease];//scrollview width and height
mainScroll.scrollEnabled = YES;
mainScroll.userInteractionEnabled = YES;
mainScroll.showsVerticalScrollIndicator = YES;
mainScroll.contentSize = CGSizeMake(width,height);//width and height depends your scroll area
..........
//add subviews to your scrollview.....
[mainScroll addSubview:view1]
............
[mainScroll addSubview:view2]
..............
[mainScroll addSubview:view3]
[self.view addSubview:mainScroll];
Note :: the contentSize property defines your scroll area.Scrolling is enabled only if your scroll content is larger than the scroll height.
source to share