IOS with Swift Hello world app.

Slides:



Advertisements
Similar presentations
View-Based Application Development Lecture 1 1. Flows of Lecture 1 Before Lab Introduction to the Game to be developed in this workshop Comparison between.
Advertisements

Whats New in Office 2010?. Major Changes in Office 2010 The Office Ribbon, which first made its appearance in Office 2007, now appears in all Office 2010.
Step-by-Step: Add a Graphical Hyperlink USE the Special Events Final presentation that is still open from the previous exercise. 1.Go to slide 4, and click.
Introduction to Microsoft Excel 2010 Chapter Extension 3.
PowerPoint 1. Multiple OUTPUT types: –Paper –Onscreen –Web presentation 6 x 6 rule –no more than 6 points per slide –No more than 6 words per point Placeholder.
Word Lesson 1 Microsoft Word Basics
Microsoft Word 2010 Lesson 1: Introduction to Word.
Word Processing First Steps
PowerPoint Scavenger Hunt Lauren Davis EDTD 3011 A Summer 2007.
Advanced Microsoft Word Hosted by Jared Hoffman Topics Keyboard Shortcuts Customizing Toolbars and Menus Auto Format & Auto Correct Tabs Inserting Pictures.
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.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Copyright 2007, Paradigm Publishing Inc. POWERPOINT 2007 CHAPTER 1 BACKNEXTEND 1-1 LINKS TO OBJECTIVES Create Presentation Open, Save, Run, Print, Close,Delete.
FIRST COURSE PowerPoint. XP New Perspectives on Microsoft Office 2007: Windows XP Edition2 What Is PowerPoint? PowerPoint is a powerful presentation graphics.
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
1 Flash Programming Introduction Script Assist. 2 Course Description This course concentrates on the teaching of Actionscript, the programming language.
Fundamentals of Programming in Visual Basic 3.1 Visual basic Objects Visual Basic programs display a Windows style screen (called a form) with boxes into.
Storyboards Managing multiple views. Overview Create a single view application Give the project a name and click “Use Storyboards” and “Use Automatic.
Using Microsoft Outlook: Basics. Objectives Guided Tour of Outlook –Identification –Views Basics –Contacts –Folders –Web Access Q&A.
Mobile App Certification Course. In this course we will work you through on how you can start developing mobile apps for yourself or for many industries.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Xcode Presentation Tom Pletzke. Creating App from template Launch Xcode Select Tabbed Application.
Advanced Forms Lesson 10.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
XP Tutorial 5 Buttons, Behaviors, and Sounds. XP New Perspectives on Macromedia Flash MX Buttons Interactive means that the user has some level.
Xcode testing Using XCTest.
Intro to the Xcode IDE and the iOS SDK CSE 391 Fall 2012 Tony Scarlatos.
Pasewark & Pasewark 1 Word Lesson 1 Word Basics Microsoft Office 2007: Introductory.
Website Development with Dreamweaver
iOS components in Swift
InteractiveMedia’s Imagine Software Platform When user clicks on the Imagine desktop icon or installed app. This is the first thing the user will see full.
Chapter 3: Using GUI Objects and the Visual Studio IDE.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Nonvisual Arrays and Recursion by Chris Brown under Prof. Susan Rodger Duke University June 2012.
In the next step you will enter some data records into the table. This can be done easily using the ‘Data Browser’. The data browser can be accessed via.
Tabbed Views UITabBarController. Controller Architecture UITabBarController Controls the first view that the user sees The view controller class (and.
Chapter 5 Quick Links Slide 2 Performance Objectives Understanding Framesets and Frames Creating Framesets and Frames Selecting Framesets and Frames Using.
Using Xcode A Beginner’s Tutorial Erin Green. This tutorial will walk you through Xcode, a software development tool for Apple’s iOS applications – We.
Basic Editing Lesson 2.
View Controllers Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
Gestures UIGestureRecognizer.
GISMO/GEBndPlan Overview Geographic Information System Mapping Object.
Nav Controllers UINavigationController. Overview Nav Controller basics Like a tabview controller, a navViewController manages views A navigationViewController.
Orientation Configuration adapting to orientation changes.
Lesson 1 - Understanding the Word Window and Creating a New Document
JDS5 Training Guide. On Start Up you will see this screen click the OK button Click OK.
When the program is first started a wizard will start to setup your Lemming App. Enter your company name and owner in the fields designated “Company Name”
When the program is first started a wizard will start to setup your Lemming App. Enter your company name and owner in the fields designated “Company Name”
1 Word Lesson 1 Microsoft Word Basics Microsoft Office 2010 Introductory Pasewark & Pasewark.
VB.NET and Databases. ADO.NET VB.Net allows you many ways to connect to a database. The technology used to interact with a database or data source is.
Microsoft Office 2007: Introductory Pasewark & Pasewark 1.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Microsoft Word Tutorial Albert Kalim. Topics You Should Know About Start MS Word Start MS Word Open a document Open a document Enter text Enter text Change.
Distribution Statement A: Unlimited Distribution Introduction to Microsoft PPT.
WebViews UIWebView. Controller Architecture UITabBarController Controls the first view that the user sees The view controller class (and xib) that manages.
Word Lesson 1 Microsoft Word Basics
Word Lesson 1 Word Basics
Creating a Presentation
iOS - First Application Anatomy
CSCI 351 – Mobile Applications Development
MODULE 7 Microsoft Access 2010
Chapter 2 – Introduction to the Visual Studio .NET IDE
Introduction to PowerPoint
CSC 581: Mobile App Development
Word Lesson 1 Word Basics
Apple Xcode with Swift Demo
CSC 581: Mobile App Development
Presentation transcript:

iOS with Swift Hello world app

Step 1 launch XCode Version 6 or more for Swift Create New Xcode project

Step 2: Choose type of project Master-Detail Applicaton: This good for Ipad (has list on left and details on larger right area)

Step 2: Choose type of project Page-Based Applicaton: Scrolling application (like iPhone home screen)

Step 2: Choose type of project Single View Application: simple with only 1 view

Step 2: Choose type of project Tabbed Application: tabs on bottom application (like app store application)

Step 2: Choose type of project Empty Application: no views specified

Step 2: Choose type of project Game: no views specified

Step 3: name project & select Swift name of application, organization, and select Swift language. Also, specify iPhone or iPad or.. Next ---and save it somewhere on machine

Step 4: setup project properties Identity: (version, etc) Deployment : (target SDK, device, main interface, orientation) Icons/Launch Images Embedded Binaries Linked Frameworks/Libraries Step 4: setup project properties We are not going to change anything from defaults except to specify it in “portrait” orientation

Lets look at File structure AppDelegate.swift Communicates with phones iOS system, tells about this app Replaces AppDelegate.m and .h from Objective-C ViewController.swift Has lifecycle methods of app and setups up main window for app. Often don’t edit Main.storyboard Used to setup interface(s) with a visual editor Images.xcassets Supporting Files HelloWorldSwiftTests = contains any testing code Products = contains

AppDelegate.swift Auto generated with project Not going to RIGHT Now alter anything here Auto generated with project Various app lifecycle methods Creating a window

ViewController Has method viewDidLoad() that we will alter to setup – like loading from nib a view

Main.storyboard Has Visual Editing interface that lets us specify multiple Views and their interfaces

Main.storyboard interface Can visually edit

Step 6: add “hello world” to single view interface we have in our Main Step 6: add “hello world” to single view interface we have in our Main.storyboard Step 6.1: select View controller

Step 6.2: Step 6.1: select View controller

Step 6.3: bring up Objects Inspector Use Objects Inspector to select widgets you want to drag and drop to your interface

Step 6.4: in inspector window Set Simulator Metrics Here choose the smaller iPhone 4 option in portrait view

Step 6.5: find Label in Objects Inspector drag and drop

Step 6.6: change properties of Label in inspector Change text, size, center it

Step 6.6: Add a Text field Make it width bigger, setup properties: set text that initially appears (placeholder)

Step 7: Add some Event handling code so your gui works Here when user types in something in the Text Field you will read it in and change the Label to say Hello “Name Entered”

Step 7.1: bring up assistant editor Lets you see storyboard AND code

Step 7.1: assistant editor—what it looks like Code –here ViewController Storyboard

Step 7.2: Create IBoutlets for all GUI widgets you want “handles to in your code Select Gui Widget in Storyboard Right Click on it and drag to ViewController code below the class statement

Step 7.2: Create IBoutlets for all GUI widgets you want “handles to in your code Now release and fill in pop-up --- give it a name (here “nameLabel”) and hit CONNECT Now you will have the following code IBOutlet is a kind of “connection” like an electrical outlet between code and the GUI NOTE: the nil here does not mean a nil object but, rather we are not changing the properties or text of the Label in the GUI

Step 7.3: Create IBActions for all GUI widgets you want handle events from Here we want to handle the even when user types (something first) and hits return in the Text Field GUI. Select Gui Widget in Storyboard Right Click on it and drag to ViewController code before end of class

Step 7.3: Create IBActions for all GUI widgets you want handle events from Now release and fill in pop-up --- Connection = action Event = “Did End On Exit” Type = “UIText Field” Argument= sender Name=(here “helloWorldAction”) Different Types, End on Exit will be created when user hits return in text box Creates dummy function that YOU must edit to create code to handle this event

Step 7.3: create even handling code Change the name of the parameter form sender to nameTextField (better to be specific) Grab the text typed in the Text Field Create string to alter the label. Remember “nameLabel” is the variable (IBOutlet) pointing to Label SWIFT Set text the setter is just .text on nameLabel Print out variable in string \(varname) NO NEED for SEMI-COLON at end of lines in swift

Step 7.4: tip: getting rid of keyboard that the TextField popped up Then inside the event handler say that the UITextField should give up its focus @IBAction func helloWorldAction(nameTextField : UITextField) { nameLabel.text = “Hi \(nameTextField.text)” nameTextField.resignFirstResponder() } This says that the UIField nameTextField is giving up its FirstResponse status ---which means it is no longer in focus, And the associated keyboard will dissapear

Step 8: run the program To run your program hit the “play/run” button in upper left of xcode You can change device type here currently set at iPhone 4 to whatever you want, like iPhone 6

A note about Storyboard Can have multiple interfaces and connections between them. a single file describes all of this These between interfaces transitions are called “segues” you create them by connecting your view controllers right in the storyboard.

Special Note about First Responder won’t be using the First Responder very much. a proxy object that refers to whatever object has first responder status at any given time.

How does everything launch??? @UIApplicationMain =says this class is launch/entry point application() function will be called NO CODE??? - see next slide AppDelegate class

It looks to Info.plist Located in Supporting Files group In android like loading up the main layout for an Activity Contains information (like Android Manifest) about the app HERE specifies the storyboard to launch

How to change the name of the Storyboard file Go to project settings

Storyboard with multiple views Getting started ….

Bring up Storyboard Zoom out so have room in interface Add “View Controller” to Storyboard

Results..of adding 2nd View Controller

Change background colors &add 3rd View Controller &add SEGUES Add some buttons that we will have Actions for to transition from one View to another Segue = Cntrl-Click on button in #1 interface and drag to #2 interface Type = show, present modally or …..

Result ---see relationship between 2 views Lets Run it 

Do similar with 2nd View’s button to segue to 3rd View Run it 

Suppose we want to add NAVIGATION Controller to 1st View Select 1st view in storyboard Menu: Editor->Embed In ->Navigation Controller Inserts a “Navigation Controller for entire app

Lets Run Right now no navigation controls added yet but, see bar area at the top. Will be there for every View in this Storyboard NOTICE: it adds Back link in 2nd View automatically

See developer.app for more on Navigation Controller

Example 2: Storyboard w/ multiple Views—started –see http://www.raywenderlich.com/81879/storyboards-tutorial-swift-part-1

Example multiple views with Storyboard Go to  Main.storyboard and delete the view controller you worked with earlier. This can be done by clicking on View Controller in the Document Outline and pressing the Delete key. Drag a Tab Bar Controller from the Object Library into the canvas. the Tab Bar Controller comes with two view controllers ZOOM tip: zoom in and out by double-clicking the canvas, or set zoom scale by ctrl-clicking the canvas and selecting the zoom level.

Example Multi View Storyboard from http://www. raywenderlich Finish by going to http://www.raywenderlich.com/81879/storyboards-tutorial-swift-part-1

Example multiple views with Storyboard  Tab Bar Controller with two view controllers

Multiple view Storyboard example—notice the relationship Between Tab Bar Controller and one of it view controllers

Finish the example at http://www. raywenderlich Finish the example at http://www.raywenderlich.com/81879/storyboards-tutorial-swift-part-1 also see http://www.swiftvideotutorials.com/using-storyboards-for-osx