Storyboards Managing multiple views. Overview Create a single view application Give the project a name and click “Use Storyboards” and “Use Automatic.

Slides:



Advertisements
Similar presentations
Managing Your Site – Lesson 61 Managing Your Site Lesson 6.
Advertisements

Grade Cam Dustin Foster 2/4/13 Please open Chrome & Login to Skyward.
Space Man Sam: Grammar Mistakes By Aleis Murphy Duke University, Under the direction of Professor Susan Rodger July 2010.
Table Views UITableView. Overview Table view basics Tables display lists of data Each item in a tables list is a row Tables can have an unlimited number.
1 After completing this lesson, you will be able to: Create a database. Create a table using the Table Wizard. Create and modify a table in Design view.
Working with Tables for Page Design – Lesson 41 Working with Tables for Page Design Lesson 4.
Detecting Collisions CSE 391 Fall 2012 Tony Scarlatos.
Getting Started with Cadence Compiled by Ryan Johnson April 24, 2002  Open Orcad Capture under Engineering Software  Under FILE, choose NEW, PROJECT.
Using Eclipse. Getting Started There are three ways to create a Java project: 1:Select File > New > Project, 2 Select the arrow of the button in the upper.
Create a calculator– 2nd iPhone programming exercise CSE 391 Fall 2012.
Microsoft Office 2010 Access Chapter 1 Creating and Using a Database.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
View Controllers (second part) Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
Create slices and hotspots Create links in Web pages Create rollovers from slices Create basic animation Add tweening symbol instances to create animation.
Inventory Throughout this slide show there will be hyperlinks (highlighted in blue) follow the hyperlinks to navigate to the specified Topic or Figure.
Ch 9 Managing Active Directory User Accounts. Objectives Create Organizational Unit Creating User Accounts in Active Directory Disabling, Enabling, and.
Sprite Animation CSE 391 Fall 2012 Tony Scarlatos.
Hello World In C++ and Microsoft Visual C++. Directions to begin a project 1. Go to All Programs 2. Open Visual Studio C++ 3. Click on New Project 4.
Xcode Presentation Tom Pletzke. Creating App from template Launch Xcode Select Tabbed Application.
SQL Maestro Hello World IQ Associates. Contents Initial setup Hello World.
Xcode testing Using XCTest.
| | Tel: | | Computer Training & Personal Development Outlook Express Complete.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 4 1 Microsoft Office FrontPage 2003 Tutorial 4 – Using Shared Borders and Themes.
iOS components in Swift
1 Databound Controls. 2 Objectives You will be able to use design time data binding to display and update SQL Server database data without writing any.
Alice 2.0 Introductory Concepts and Techniques Project 1 Exploring Alice and Object-Oriented Programming.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 5 Enhancing Forms with OLE Fields, Hyperlinks, and Subforms.
Updating the Laboratory Website. Useful Info Address: Everything is saved in the desktop.
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
Tabbed Views UITabBarController. Controller Architecture UITabBarController Controls the first view that the user sees The view controller class (and.
Navigation in iPads splitViewController. Overview Create a Master-Detail application Switch Device Family to iPad Give the project a name and click “Use.
IOS with Swift Hello world app.
Chapter 5 Quick Links Slide 2 Performance Objectives Understanding Framesets and Frames Creating Framesets and Frames Selecting Framesets and Frames Using.
Managing Multiple Views and Segues FA 172 Intro to Mobile App Development.
Macromedia Dreamweaver 8-- Illustrated Introductory 1 Macromedia Dreamweaver 8 Unit B Creating a Web Site.
Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )
View Controllers Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
Course ILT Forms and queries Unit objectives Create forms by using AutoForm and the Form Wizard, and add or modify form headers and footers Open and enter.
Gestures UIGestureRecognizer.
Passing data between storyboard views Singleton pattern.
Nav Controllers UINavigationController. Overview Nav Controller basics Like a tabview controller, a navViewController manages views A navigationViewController.
Orientation Configuration adapting to orientation changes.
Metalib Categories Administration. 2 The MetaLib Management interface is used for set up procedures relating to categories. Using the Categories Administration.
Web Design-Lecture3-QN-2003 Web Design Enhancing a Website.
After clicking the link, you will be taken to this page. Both the StudyCards™ and TI StudyCards™ Creator for Windows® needs to be downloaded. The first.
Lesson 14: Exploring Excel Learning Objectives After studying this lesson, you will be able to:  Explain ways Excel can help your productivity.
Getting Started with Word & Saving Guided Lesson.
CPS-Student Response System Dottie Betts ITRT June 2009.
HTML Concepts and Techniques Fifth Edition Chapter 3 Creating Web Pages with Links, Images, and Formatted Text.
Web Page-Chapter 6 Forms. Inserting a Form  Display the Insert bar  Click the arrow to the right of the display category on the Insert bar and then.
Lecture 10 Using Interface Builder to create Mac Applications.
1 Reverse a String iPhone/iPad, iOS Development Tutorial.
Basic Filmmaking. Converting File Formats: First, you have to convert your video files to a different format so the editing software will recognize it.
Folio3 IPhone Training Session 2 Testing App on device Presenter: Imam Raza.
Interactive PPT Directions. IMPORTANT!  Before you make any hyperlinks or action buttons, you should create the slide that you want to link to and give.
Building a Website: Layout Fall Overall Structure: Home Page Title Section Title Frame Picture UNCP Math Menu Content Footer Contact Information.
 You can fix any verbal/visual errors  To make it more interesting by adding transitions and music  To be able to add it to your My Big Campus online.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
This is what we want to produce Import sketch dimensions Label angles Set the scale Add linear dimensions.
CIS 205—Web Design & Development Flash Chapter 3 Working with Symbols and Interactivity.
Introduction to PowerPoint 2003 Professional Development Training for Classroom Teachers.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
WebViews UIWebView. Controller Architecture UITabBarController Controls the first view that the user sees The view controller class (and xib) that manages.
iOS - First Application Anatomy
Designing with Introspection
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
How to PostPower Point Presentations
EEC-492/693/793 iPhone Application Development
CSC 581: Mobile App Development
Presentation transcript:

Storyboards Managing multiple views

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 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 No icon view View Controller First Responder Exit 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)

The storyboard Select the MainStoryboard.storyboard file When you’re zoomed out you cannot select components or drag new components to the view No icon view Change between iPhone 4 size and iPhone 5 size Zoom buttons Editing conttrols

Testing Add label. Run.

Files CMPViewController.m Very few methods CMPAppDelegate.m Bunch of empty methods Application:didFinishLaunchingWithArguments: Different from previous apps Used to build a UIWindow, viewController, etc.

Files Go to project navigator on left, select topmost file name, make sure the target is selected in next column and summary tab is clicked. Look for iPhone/iPod Deployment Info section. MainStoryboard is configured as the Main Storyboard That’s how the app knows to automatically create a window. All the code is behind the scenes.

Files

app We’ll create an app with three views: a red view, Has count of number of times it has been displayed Has buttons to the green and blue views a green view Has count of number of times it has been displayed Will have a back button a blue view Has count of number of times it has been displayed Will have a back button

Red View First refactor current CMPViewController to redViewController In Xcode 4: Control click or right click on the name CMPViewController.h in the project navigator Choose Refactor=>Rename Enter redViewController. Make sure to check the checkbox for “Rename related files” in the ensuing dialog box choose “enable” then “save” when I did this, redViewController.m was not included correctly. If it shows up in red, delete it (but do NOT move to trash), then add it again. Sometimes Xcode puts the.m file in the wrong folder on your hard drive. Ensure that the redViewController.m file is in the same folder as all of your other.m files. Xcode 5: 1.click on fileName.h in navigator window 2.highlight the name of the class (right after at the top of the file) 3.Choose Edit->refactor->rename

Red View Go to MainStoryboard.storyboard In the dock, click on the Red View Controller Choose the identity inspector. The class should be a redVewController

Red View Change the background color to red Make the label large and the value 0 Add two buttons “blue” and “green”

redViewController.h Add redViewController : (nonatomic) int redCount; // number of times visit red (nonatomic) int greenCount; // number of times visit green (nonatomic) int blueCount; // number of times visit blue (weak,atomic) IBOutlet UILabel

redViewController.m Need to count whenever view appears. Where should we count this? viewDidLoad? − (void)viewWillAppear: (BOOL)animated { [super viewWillAppear:animated]; self.countLabel.text = [NSString ++self.redCount]; } Pre-increment redCount, create a string out of it, set the text of the label.

storyboard Make sure the countLabel property is connected to the label in the storyboard.

run Nothing should happen. Yet. But you should see your red view with the number “1”

More View Controllers Click on the MainStoryboard.storyboard Go to library and drag a viewcontroller to the storyboard (not inside the present view) repeat

More View Controllers Now go to File=>New=>File and choose objective C class. Name it greenViewController but do not include a nib file. We already created the view in the storyboard file make sure it is a subclass of a viewController Make sure it’s not for iPad Make sure the checkbox by Targets is checked. Repeat and name the new file blueViewController

More View Controllers Go to MainStoryboard.storyboard Select one of the new views and change the background color of the view to green. Make sure the viewController is selected. Go to the identity inspector Change the class to greenViewController

More View Controllers Add a label, a “go back” button,.

More View Controllers Add to the greenController.h greenViewController : (weak,atomic) IBOutlet UILabel (nonatomic) int

More View Controllers Adde to the greenController.m file - (void)viewWillAppear: (BOOL)animated { [super viewWillAppear:animated]; self.countLabel.text = [NSString self.viewCount]; } Note that we use viewCount as the variable and we do NOT increment it! Will do this in the redViewcontroller

More View Controllers Make sure that the countLabel property is connected to the UILabel in the storyboard

More View Controllers Repeat this process for the blue controller and blue view.

Run Should see red view with a count of “1” No connections to other views yet In the MainStoryboard.storyboard file, move the big arrow that is on the left side of the red view to the left side of the green view Run Should see the green view with a count of “0” Repeat for the blue view

Segue A segue specifies a transition from one view controller to another These transitions form a stack Just like a navigation controller When a segue is triggered (ours will be by a button), the segue is followed to the next view, That view is pushed on the stack That view is displayed Then the view can be dismissed Popped from stack, top of stack view is displayed Or a new segue can be triggered The new view controller is pushed on the navigation stack The new view is displayed

Segue In our app, when the “green” button is pushed, the green view controller will be pushed on the stack There will be a transition The red view controller will update the greenCount The red view controller will update the label in the green view.

First Segue Go to the MainStoryboard.storyboard Control click on its Green button and drag to the GreenViewController Let go and a menu asks what type of segue to create Select Modal; Our segue is created (see next slide)

Segue 1

Select the segue (click on the circle in the middle of the arrow) Select the attributes inspector Name the identifier “green” Make the transition “Flip Horizontal”

Run Green button should work Green view label does not update yet. Go back button does not work yet.

Segue 2 Repeat with blue button and blue view. It’s identifier should be “blue”

Connecting In greenViewController.h add an IBAction: − (IBAction)handleGoBack:(UIButton *)sender; In greenViewController.m add: − (IBAction)handleGoBack:(UIButton *)sender { [self dismissViewControllerAnimated: YES completion: NULL]; } And connect the Go Back button in the storyboard to this method

Counting Want the redViewController to count for both green view methods and blue view methods So the redViewController needs to know when a segue is done to one of these views And it must be able to change the instance variable in each of them.

Counting The prepareForSegue method in the redViewController is called just before a segue is done. This method passes in a pointer to the segue that is about to be done. We’ll use the identifier that we added to the segue to determine which view we’re going to.

Counting In the redViewController.m file add at top of file: #import "greenViewController.h" #import "blueViewController.h"

Counting In the redViewController.m file add: − (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ if ([segue.identifier { greenViewController *vc = (greenViewController *) segue.destinationViewController; vc.viewCount = ++self.greenCount; } else if ([segue.identifier blueViewController *vc = (blueViewController *) segue.destinationViewController; vc.viewCount = ++self.blueCount; }

Run Then connect the blue and green views with buttons.

More Control You can create tab controllers and navigation controllers (using tables) with storyboards