Getting started with iOS5 storyboards (1)

Source: Internet
Author: User
The story board is an exciting new feature in iOS5, which greatly saves you time writing user interfaces. To understand what a storyboard is, see. This is also the storyboard that will be created in this tutorial: Original: http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1

The story board is an exciting new feature in iOS5, which greatly saves you time writing user interfaces. To understand what a storyboard is, see. This is also the story board created in this tutorial:

In the new iPhone/iPodDeployment Info section, you can choose whether to start from the storyboard file or from the nib file.

To make it clearer, open main. m to view:

#import 
 
    #import "AppDelegate.h"  int main ( int argc, char * argv []) {        @autoreleasepool {               return UIApplicationMain ( argc, argv, nil ,                            NSStringFromClass ([ AppDelegate class ])) ;     }}
 

The last parameter of the original UIApplicationMain () is nil, but now it is NSStringFromClass ([AppDelegate class]).

Different from using MainWindow. xib, the storyboard does not contain application delegation. Since the application delegate cannot be loaded from nib or from the storyboard file, we must tell the name of the UIApplicationMain application delegate class, otherwise, it cannot find the application delegate class.

Use TabBar

The Ratings program has a Tabbar that contains two viewcontrollers. Creating a Tabbar using a storyboard is a trivial task.

Switch to MainStoryboard. storyboard and drag a TabBarController to the canvas. You may have to maximize the Xcode window. because TabBarController is associated with two viewcontrollers, you may need more space for flexible operations.

The new TabBarController has already configured two viewcontrollers in advance, one for each Tab button. UITabBarController is a ViewController container that contains multiple viewcontrollers. Other similar containers include NavigationController and SplitViewController ). IOS5 has a cool feature: you can write your own ViewController container-which will be introduced in subsequent tutorials in this book.

The inclusiveness relationship between TabBarController and the included ViewController is represented by an arrow (with a circle icon in the middle.

Note: If you want to move TabBarController along with its ViewController, use Cmd + left-click to select and move all of them (the selected scenario will be framed by a light blue square ).

Put a Label in the first ViewController and enter the text "FirstTab ". Put a Label in the 2nd ViewController and enter the text "Second Tab ". In this way, we can switch the Tab time zone to two viewcontrollers.

Note: You cannot drag something to the scene in the zoom mode of the editor. you must first restore it to the normal mode.

Select TabBarController and open the properties panel. Select "IsInitial View Controller.

TabBarController has two relationships: one is a Tab. NavigationController has a relationship with TableViewController. In addition, there is another arrow, "segue", which we will talk about later.

When a new connection is created, the new Tab is also added to the TabBarController, and its name is "Item ". I want to place new scenarios on the first Tab. you can drag and drop tabs to change their order.

Run the program. now the first Tab has become NavigationController.

Before we add the actual functions to the app, let's sort out our storyboards. I want to name the first tab Players, and the first 2nd tabs Gestures. Instead of changing the TabBarController, you need to change the ViewController corresponding to the tab.

When you connect a ViewController to the TabBarController, a TabBarItem object is created on the ViewController. With the TabBarItem object, you can set the Title and image of the Tab.

Select the TabBarItem object on NavigationController. on the property Panel, set its Title to Players.

Rename the TabBarItem of the second ViewController to Gestures.

You can also add images to the Tab. In the source code of this tutorial, there is a folder Images. Add the folder to the project. On the attribute panel of TabBarItem "Guestures", set Players.png to its image. Set the image of TabBarItem "Players" to Players.png.

Similar to this, there is a NavigationItem object on the ViewController contained in NavigationController, which can be used to set the navigation bar. Select NavigationItem on TableViewController and change the title to Players in the properties panel.

Of course, you can also simply double-click NavigationBar to modify the title (note: you should double-click the "fake" navigation bar on TableViewController, instead of double-click the real navigation bar on NavigationController.

To run the program, you do not need to write a line of code. the customized Tab bar is displayed.

The above is the content for getting started with iOS 5 storyboard (1). For more information, see PHP Chinese website (www.php1.cn )!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.