[iOS beginner]ios first article storyboard and viewcontroller relationship

Source: Internet
Author: User

Learning a bit of iOS, a basic concept to clear up, in Android or WP, we basically are accustomed to a scene with a picture of a class, the new scene when the newly created class, but in the use of iOS storyboard found, After adding a new Viewcontroller in storyboard, I don't know where to write the code to control the Viewcontroller, because the default initialization creates the app automatically with a viewcontroller.

For me, this is not clear from the beginning, like the following diagram, a new viewcontroller is established directly in the storyboard. In fact

You should manually create a new Viewcontroller class and associate the VC in storyboard to a specific VC code file

Specific as follows

is to choose a new file to create in my project

, I still choose my swift file,

The viewcontroller that I want to associate with in storyboard is the class file that I customized in Customclass in the property menu on the right. Of course, it should be in class to write the relevant code is the same as the new project when the VC class code

Import Uikit//cnblog There is no swift, will use the C format to insert the code highlighted in the place is not displayed ==!  class  sviewcontroller:uiviewcontroller{    override  func viewdidload () {    println ("view2")    }        }

This basically completes the operation of creating a new activity similar to that in Android.

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.