# Storyboards

## Overview

This tutorial describes how to create a new application using storyboards by using the CJGuestCallViewController. This high-level SDK object is useful for demo purposes.

## Requirements

The requirements for the SDK can be found in the Developer Guide.

## Steps

The following steps show how to piece together the application.

1. Create A New Project

   Create a new project in Xcode and use the Single View Application template.

2. Add the SDK to Your Project

The installation instructions for the SDK can be found in the Developer Guide.

3. Add CJGuestCallViewController

1. From the Project Navigator, select Main_.storyboard. If you selected to create a universal app you will see a storyboard for both iPad and iPHone.
2. Select the View Controller Scene from the Document Outline.
3. Select Editor > Embed In > Navigation Controller to add a master navigation controller.
4. Select the View in the storyboard and drag a Label from the Object Library and place it in the middle of the View.
5. Change the label text to Guest Call Storyboard View.
6. Drag a Bar Button Item from the Object Library to the View Controller's Navigation Item at the top left and change the title to Video Support.
7. Drag a View Controller from the Object Library to the storyboard.
8. Change the Class of the View Controller (under Identity Inspector) to CJGuestCallViewController.
9. Hold down the Ctrl key and drag a link from the Video Support button to the Guest Call View Controller to create a segue.
10. Select the segue and from the Attributes Inspector change the Identifier to StartJabberGuest.
11. Your completed storyboard should look like this.

12. In your ViewController.m add prepareForSegue to handle the StartJabberGuest segue, and implement a delegate method to dismiss the Guest Call View Controller once the call is finished.

        #import "YourViewController.h"

        #import <JabberGuest/JabberGuest.h>

        @interface YourViewController () <CJGuestCallViewControllerDelegate>

        @end

        @implementation YourViewController

        - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
        {
            if ([[segue identifier] isEqualToString:@"StartJabberGuest"]) {

                CJGuestCallViewController * jabberGuest = [segue destinationViewController];

                jabberGuest.serverName = @"your.server.name";
                jabberGuest.toURI = @"your.uri";
                jabberGuest.delegate = self;
            }
        }

        - (void)callFinishedForCallController:(CJGuestCallViewController *)callController
        {
            callController.navigationController.navigationBarHidden = NO;
            [callController.navigationController popViewControllerAnimated:YES];
        }

        @end

4. Build and Run the Application

Build and run the application on your iOS device. You should be able to play a video call to the URI you set in the `prepareForSegue: sender:` method.