100 likes | 205 Views
Storyboards II. Tabs and Tables. Overview. Create a single view application Give the project a name and click “Use Storyboards” and “Use Automatic Reference Counting” Save it somewhere. Do not create a git directory. There’s no nib; instead the storyboard represents several views.
E N D
Storyboards II Tabs and Tables
Overview • Create a single view application • Give the project a name and click “Use Storyboards” and “Use Automatic Reference Counting” • Save it somewhere. Do not create a git directory There’s no nib; instead the storyboard represents several views
The storyboard • Select the MainStoryboard.storyboard file No icon view When you click on View Controller in the doc, you get 3 icons: each View in the storyboard has these icons. This is called a scene This arrow shows which view controller is the initial view controller for this storyboard. Can drag this arrow to another view (if there was one) Exit View Controller First Responder
The storyboard • Select the MainStoryboard.storyboard file No icon view When you’re zoomed out you cannot select components or drag new components to the view Zoom buttons Change between iPhone 4 size and iPhone 5 size Editing conttrols
Testing • Add label. • Run.
Second Controller • Select the storyboard and add a new view controller • Put a label on the first view controller’s view that says “View Controller 1” • Put a label on the second view controller’s view that says “View Controller 2” • Select the first view controller and invoke the following menu command • Editor ⇒ Embed In ⇒ Tab Bar Controller • A Tab Bar Controller is added and the first view controller has been automatically configured to be its first tab (!) • Your storyboard should now look similar to the next slide
Second Tab • Control-Click on the Tab Bar Controller and drag to the second view controller • Let go and a menu appears with more options than in our previous example • In particular, there’s a new section called “Relationship Segue” and a choice under that which says “view controllers” • Select the “view controllers” choice • this essentially says that we’d like the second view controller to be one of the view controllers managed by the tab bar controller • You should see a Tab Bar with two tabs • If you run it, you can click on the two tabs to see your two view controllers in action • Tabs
Tab bar buttons • Add two icons to the project • Click on the first view controller. Then click on its tab icon. • Go to the attributes inspector. • Give each a name and an icon • Repeat with second controller • Run. • Tabs