Easy Tutorial
❮ Ios First Iphone Application Ios Tutorial ❯

iOS Storyboards


Introduction

Storyboards were introduced in iOS 5, and when using Storyboards, the deployment target should be iOS 5.0 or later.

Storyboards help us visualize the flow of screens in the interface.

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 the view controller as shown below.

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

  4. Now select "modal" from the three display options shown below.

  5. Update ViewController.h as shown below:

    #import <UIKit/UIKit.h>
    
    @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" and right-click the "Exit" button, then select and connect the back button in the right view controller, as shown below.

Output

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

Now, select the modal display to get the following output:

❮ Ios First Iphone Application Ios Tutorial ❯