Setting The Whole View As Scroll View
Create a new ViewController as normal and drag on a Scroll View object.
In The #ViewController.h File
IBOutlet UIScrollView *MainScrollView;
In The #ViewController.m File
//***********************************
//***********************************
//********** VIEW DID LOAD **********
//***********************************
//***********************************
- (void)viewDidLoad
{
[super viewDidLoad];
//----- SET THE SCROLL VIEW SIZE -----
MainScrollView.contentSize = CGSizeMake(320,1000); //(This is required in code - can't be set in interface builder)
}
//*************************************
//*************************************
//********** VIEW DID UNLOAD **********
//*************************************
//*************************************
- (void)viewDidUnload
{
[super viewDidUnload];
[MainScrollView release];
MainScrollView = nil;
}
//*****************************
//*****************************
//********** DEALLOC **********
//*****************************
//*****************************
- (void)dealloc
{
[MainScrollView release];
[super dealloc];
}
In The #ViewController.xib File
Right Click the ‘Files Owner’ box and drag the MainScrollView outlet onto the new Scroll View.
Setting The Whole View As Scroll View – Other Method
Create a new ViewController as normal.
In The #ViewController.xib File
Drag a Scroll View onto the view so it fills it.
Right Click the ‘Files Owner’ box and delete the existing ‘view’ outlet. Drag the now unassigned ‘view’ outlet to the new Scroll View.
Select the Scroll View and select the Size Inspector properties panel. Set the desired ‘Height’ or ‘Width’ in the View panel.
In The #ViewController.m File
//***********************************
//***********************************
//********** VIEW DID LOAD **********
//***********************************
//***********************************
- (void)viewDidLoad
{
[super viewDidLoad];
//----- SET THE SCROLL VIEW SIZE -----
UIScrollView *tempScrollView = (UIScrollView *)self.view;
tempScrollView.contentSize = CGSizeMake(320,1000); //(This is required in code - can't be set in interface builder)
}
To Edit The Scroll View Contents In Interface Builder
Although you have set the scroll view size in the interface builder you can’t actually see the entire view apart from when dragging it. The solution to this is a bit of a pain but it does the job – set the View panel X or Y values to -# to move the area of the scroll view that is visible