IOS Study Notes (12) storyboards usage

Source: Internet
Author: User

Storyboards

Storyboards is a new method that defines the connection between different screens in the app. With storyboards, you can browse and create the UI of the entire app, and establish a connection before different view controllers on the screen.

The content of a screen is called a scenario.

Create a project with storyboards

In the new Project Settings dialog box, select use storyboard.

Add a navigation controller to the storyboard

The storyboard file is opened in Ib. You only need to double-click the space on an empty Series Image printprint cloth to narrow down the content.

I have used storyboard briefly. Now I will introduce how to use it:

Open. after the storyboard file, there is a whiteboard View Controller. We need to add a navigation controller. In the object library, we find the navigationcontroller object and drag it to the canvas on the left, two view controllers are added to the canvas. we delete the View Controller pointed to by the arrow. Select the remaining navigationcontroller controller, press the control key, press the left mouse button, and pull out a straight line until the viewcontroller controller (new built-in whiteboard Controller ), after you open the left mouse button and the control key, a prompt box is displayed. Click rootviewcontroller. This is only the first step. After this is done, a blank screen is displayed when you run the program screen.

The most important part is that there is a View Controller scene interface on the left side of the canvas. After selecting the navigation controller, click the View menu and choose View> show attributes inspector) [that is, the fourth left of the six charts in the upper right corner of xcode]. Select a single region after initial scene.

Now you can run the program.

Add a button and click it to push a View Controller to the stack.

Find the View Controller object in the object library, drag it to the canvas, select a button, and put it in the first View Controller (if the View Controller is in the zoom-out status, no button can be added, after the button is selected, hold down the control and left mouse buttons on the keyboard and drag them until the second view controller. Release the left mouse and control keys and select push. The running effect is displayed.

Transfers data from one screen to another

Use a segue object. (Segue [segwei] continue)

When a conversion occurs between different scenarios, the storyboard runtime creates a segue object for this conversion. An instance of uistoryboardsegue. When a conversion occurs, the current view controller (exit the screen after the segue) will receive a message of prepareforsegue: Sender:. The prepareforsegue parameter here will become an object of the uistoryboardsegue class, to transmit data, use the prepareforseue: Sender: method.

-(Void) prepareforsegue :( uistoryboardsegue *) segue sender :( ID) sender {

Nslog (@ "Source controller = % @", [segue sourceviewcontroller]);

Nslog (@ "Destination controller = % @", [segue destinationviewcontroller]);

Nslog (@ "seue identifier = % @", [seue identifier]);

}

Add a storyboard to an existing project

Choose new> New File> resource> storyboard from the File menu, and click Next.

Select the appropriate device sequence (iPhone, iPad) and click Next.

Select a save location.

Find the info. plist file in your project structure. If you have these keys, delete them from the. plist file:

* Nsmainnibfile (it will appear in the main NIB file and name ).

* Nsmainnibfile ~ IPad (the main NIB file and name will appear (IPAD )).

If you only have apps for the iPhone or iPad, create a key called uimainstoryboardfile for the iPhone or create a file called uimainstoryboardfile for the iPad ~ IPad Jian. If you have a common app, you can create two Jian. Then save the. plist file.

In the last release, the application: didfinishlaunchingwitexceptions: method is deleted from the execution of the app delegate. You can create different view controllers and Windows based on how your app is created. With storyboard, you no longer need it.

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.