Adding and configuring the Storyboard

Getting ready

In this recipe, we will learn how to add and configure an application's project properties using Xcode so that it is set up correctly to use a Storyboard file.

How to do it...

To begin, follow these simple steps as outlined in the following order:

  1. Select the BooksLibrary project from the Project Navigator window.
  2. Choose File | New | File…or press Command + N
  3. Choose the Storyboard template from the list of available templates, located under the User Interface option within the iOS section.
  4. Click on the Next button to proceed to the next step in the wizard.
  5. Ensure that you have selected iPhone from under the Device Family drop down.
  6. Click on the Next button to proceed to the next step in the wizard.
  7. Specify MainStoryboard.storyboard as the name of the Storyboard file within the Save As field as the name of the file to be created.
  8. Click on the Create button to save the file to the folder specified.
  9. Our next step is to manually configure our project so that it recognizes and uses this file for our application. This can be achieved by following these steps:
  10. Select the BooksLibrary project from the Project Navigator window.
  11. Next, select your project target from under the TARGETS group and select the Summary tab.
    How to do it...
  12. Select MainStoryboard from the Main Storyboard drop down.

How it works...

In this recipe, we learned how to manually add new Storyboard template to your project. We then looked at how to configure our project properties so that it is set up to use the Storyboard user interface file by our application.

There's more…

Finally, when using Storyboards, we don't need to create a new UIWindow as this will create another window instance, and place this on top of the Storyboard. We need to modify our application's delegate AppDelegate.m class as shown in the following code snippet:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
   // Override point for customization after 
   // application launch.
   return YES;
}
}

Note

For more information about using Storyboards in your applications, you can refer to the Apple Developer Documentation located at: https://developer.apple.com/library/ios/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/InterfaceBuilder/InterfaceBuilder

See also

  • The Creating the Books Library user interface recipe
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset