Swift development-Storyboard usage tutorial, swift-storyboard

Source: Internet
Author: User

Swift development-Storyboard usage tutorial, swift-storyboard

If the App contains many different pages, using Storyboard can help you reduce the code for redirecting between pages. In the past, developers created interface design files ("nib" or "xib" files) for each View Controller. Now, only one Storyboard can capture the interface design of all view controllers and their association.

Storyboard has many advantages:

  • With Storyboard, you can better understand all the views in the App and their associations. It is easier to control the global structure, because all designs are included in one file, rather than scattered in many separate nib files.

  • Storyboard can describe the transition between different views. This transition is called "segue" (meaning "transfer", while "Storyboard" originally meant "mirror", all originated from movie terms ), you can directly create a transition by connecting different view controllers in the Storyboard. Thanks to the transfer, there is less code to manage the interface than before.

  • Storyboard makes it easier to process table views through the new prototype cell and static cell features. The design of the table view can be almost completed in the Storyboard Editor, which also reduces the amount of code.

  • Storyboard makes Auto Layout easier. The Automatic Layout function allows you to determine the position and size of elements by defining mathematical relationships between interface elements, greatly simplifying the adaptation of screens of different sizes. Automatic Layout is not within the scope of this tutorial. For more information, see automatic layout.

Storyboard may not be suitable for you if you hate Interface Builder or want to use code to handle all interfaces. My personal opinion is that the code can be written less, especially the UI code, so Storyboard is a powerful tool for me.

If you want to continue using nib, continue using it. You must know that nib can be used in Storyboard, and the two are not mutually exclusive.

:

1. Open Xcode, create a new project, and select swift as the language.

2. Disable Auto Layout and Size Classes in File inspector of the current Storyboard.

3. Delete the original View Controller in Main. storyboard.

4. Drag a Tab Bar Controller from the object library to the Panel. Click the blank area to zoom in and out the view.

5. Run. An error is reported.

Failed to instantiate the default view controller for UIMainStoryboardFile 'main'-perhaps the designated entry point is not set?

No entry is set, that is, the initial view controller is not set after the first scenario is deleted. To solve the problem, select the tab Controller and select Is Initial View Controller in Attributes Inspector.

6. Run OK again.


Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.