This video is a bit different then the article below.
To use a View Controller we need to setup a Project with the following steps. For more detailed instructions, see article on how to Make a Hello World App.
- Start Xcode
- Click on Create a new Xcode project
- Select Single View Application and click Next
- Enter a Product Name and click Next
- Select a folder where you want to save the Project and click Create
Now we are ready to create the View Controller.
Start by selecting File > New > File from the menu at the top of the screen.
Select Objective-C Class and tap Next.
Enter a Class name. By default, Xcode will attach "ViewController" at the end. Click Next.
Select a Folder to save the View Controller, or just accept the default and click Create. At this point you should see two files ending in .h and .m, see screen shot below.
Your view controller has been created and Xcode is displaying some Objective-C code. Now what? Let's see some other things that are associated with our View Controller that we'll use in other lessons.
Clicking on Main_iPhone.storyboard in the Project Navigator (left-hand panel) will display a hierarchical view your View Controller which you can expand or collapse by clicking on the triangle, see pink arrow in screen shot below. You will also see a visual representation of the view in the middle-right panel. If you don't see this, move the mouse over the middle-right panel and use pinch to zoom in or out until you see the blue box. You may also have to click in the panel and swipe to reposition the blue box in the center of the panel.
So now you've created a view controller and seen some of the tools Xcode provides to manipulate it. In future lessons will discover what we can do with View Controllers.
Credits:
Thanks to Artur Adib, Senior Software Engineer at Twitter, for his help.
No comments:
Post a Comment