Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

iOS Storyboards

IOS Storyboards


Introduction

Storyboards were introduced in iOS 5; when using Storyboards, the deployment target should be iOS5.0 or later.

Storyboards help us understand the visual flow of screens, in an interface called

MainStoryboard.storyboard, where all application screens are created.

Example Steps

  1. Create a single view application and select the storyboard checkbox when creating the application.

  2. Select MainStoryboard.storyboard, where you can find a single view controller. Add a view controller and update it as shown below

storyboardInterface

3. Connect the two view controllers. Right-click the 'show modal' button on the left view controller and drag it to the right view controller, as shown below:

storyboardButtonAction

4. Now choose modal from the three display options shown below

storyboardButtonActionModal

5. Update ViewController.h as shown below



#import 



@interface ViewController : UIViewController



-(IBAction)done:(UIStoryboardSegue *)seque;



@end

6. Update ViewController.m as shown below



#import "ViewController.h"



@interface ViewController ()



@end



@implementation ViewController



- (void)viewDidLoad

{

    [super viewDidLoad];    

}



- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

-(IBAction)done:(UIStoryboardSegue *)seque{

    [self.navigationController popViewControllerAnimated:YES];

}



@end

7. Select 'MainStoryboard.storyboard', right-click the 'Exit' button, and select and connect the back button in the right view controller, as shown below

storyboardButtonExitAction

Output

Run the application on an iPhone device to get the following output

storyboardOutput1

Now, select modal display to get the following output

storyboardOutput2