i am going to show you all how to use scroll view in xcode and make it work.
1. Create single view application
2. Enter your application name
3. click next selecting the appropriate device
4. select the application name and unselect the device orientation landscape left and landscape right
5.click on the view controller then go to the first tab (file inspector), then unselect “use Auto Layout”
6. Similarly go to the fourth tab (simulated Metrics), select the size as freeform.
7. Now click on the view just below the view controller , select the measurement tab on the right hand side, then increase the height and fix the width as per your requirement.
8. Now using the object library, drag the scroll view to the storyboard within view.
9. Now go to viewcontroller.h and add the following code for scrollview
@interface ViewController : UIViewController
{
IBOutlet UIScrollView *scroller;
}
@end
You can view above code in below image:
10. Now go to viewcontroller.m and within viewDidload enable scrollview to yes.
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[scroller setScrollEnabled:YES];
[scroller setContentSize:CGSizeMake(320, 568)];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Above code is shown clearly in the below image:
Now you are almost done with the tutorial.
11. Now go to storyboard.
12. Add some controls like label at the top and extreme bottom to get scrollview effect.
13. Now finally click on the view controller then go to the sixth tab (Connections inspector) , there you find the outlets defined earlier by us.
14. Now drag the scrollview outlet ie, scroller to the scrollview of the storyboard
15. Then finally you get scroller referencing view controller as shown in below figure.
16. Now run the project and you get scrolling effect in your application
Enjoy Coding