Storyboard use points in iOS record

Source: Internet
Author: User

Summary:

The use of storyboard with the original single xib file is still somewhat different, in the habit of some discrepancy. Write down the key points you are experiencing here.


1. Set the first Viewcontroller to Navigationcontroller property

Typically when you create a new project. Comes with a Viewcontroller class. Storyboard also has 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. New drag out 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 arrows pointed to the view, the arrows point to our original view, In the left sidebar 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 the storyboard and then associate it with a controller, and we assume that we want to invoke the display of the interface. It is not possible to create an instance of the controller using the traditional method and then show it. 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 is black. The following methods 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

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.