Storyboard use points in iOS record

Source: Internet
Author: User

Summary:

The use of storyboard with the original single xib file use or some different, in the habit will be some discrepancy, here to write down the points encountered.


1. Set the first Viewcontroller to Navigationcontroller property

Normally when you create a new project, you will bring a Viewcontroller class, and storyboard will have a ready-made view bound to it, unlike in the past, there is no code in appdelegate that directly sets the view controller as the root view. If you want to set this view controller to a Navigationcontroller and push other sub-interfaces, use the following method:

In the storyboard file, a new drag out of a navigationcontroller, placed on the left side of the original view, after releasing the mouse, there will be two views, the middle of the arrow connected, now delete the view where the arrows point to, the arrows point to our original view, In the left column you can see the new Nacigationcontrollerscene root view (root view Controller) that points to our view. Then don't forget to point the arrows that represent the original interface to the Navigationcontroller we dragged out so that our view has the properties of Navigationcontroller.


2. Call the controller that is bound to the view in storyboard

We create a new view in storyboard and then associate it with a controller, and then if we want to invoke the display of this interface, we use the traditional method to create a new instance of the controller and then show that it is not possible, This will only show what the code in the controller has written, the content set in storyboard is not displayed, and most obviously the background of the view will be black. The following method should be used:

        We have to find view! through storyboard.        Uistoryboard *storyboard = [Uistoryboard storyboardwithname:@ "Main" bundle:nil];        Nextviewcontroller *NEXTVC = [Storyboard instantiateviewcontrollerwithidentifier:@ "Nextviewcontroller"];        [Self.navigationcontroller PUSHVIEWCONTROLLER:NEXTVC Animated:yes];

Don't forget to define the view's identifier in the view properties in storyboard, that is, the code above finds the view's credentials.



Constantly updated ...



Reprint please indicate the source, thank you

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Storyboard use key records in iOS

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.