iOS - First Application Anatomy

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

Telerik Software Academy Mobile apps for iPhone & iPad.
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.
Storyboards Managing multiple views. Overview Create a single view application Give the project a name and click “Use Storyboards” and “Use Automatic.
Sprite Animation CSE 391 Fall 2012 Tony Scarlatos.
Xcode Presentation Tom Pletzke. Creating App from template Launch Xcode Select Tabbed Application.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
iOS components in Swift
1 Designing with a UIToolBar iPhone/iPad, iOS Development Tutorial.
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.
View Controllers Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
Nav Controllers UINavigationController. Overview Nav Controller basics Like a tabview controller, a navViewController manages views A navigationViewController.
1 UI Alert View iPhone/iPad, iOS Development Tutorial.
Lecture 10 Using Interface Builder to create Mac Applications.
The iOS Platform and SDK. iOS iPhoneiPad Mini iPad.
Web Site Development - Process of planning and creating a website.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
WebViews UIWebView. Controller Architecture UITabBarController Controls the first view that the user sees The view controller class (and xib) that manages.
© Ms. Masihi.  A Web page contains text and images that convey specific information to viewers.  To create a new web page, open Dreamweaver and select.
Cliquez pour modifier le style du titre Cliquez pour modifier les styles du texte du masque Deuxième niveau Troisième niveau Quatrième niveau Cinquième.
Location And Maps Sisoft Technologies Pvt Ltd
Introduction to iOS App Development Environment
Drawing And Animations
Microsoft Visual Basic 2010: Reloaded Fourth Edition
Forms Concepts Triggers Fired when Internal/External events occur
Working with Data Blocks and Frames
IOS Design Patterns Sisoft Technologies Pvt Ltd
Welcome! Workshop 3 of 7.
Mobile Application Development with MeeGo™ - Touch Apps & UI Design
Working in the Forms Developer Environment
iOS UI Components Sisoft Technologies Pvt Ltd
Notification Sisoft Technologies Pvt Ltd
CONTENT MANAGEMENT SYSTEM CSIR-NISCAIR, New Delhi
About SharePoint Server 2007 My Sites
Learning the Basics – Lesson 1
Registering And Joining Developer Program
CONTENT MANAGEMENT SYSTEM CSIR-NISCAIR, New Delhi
Media Library Sisoft Technologies Pvt Ltd
Designing with Introspection
Activities and Intents
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
Understanding an App’s Architecture
Introduction to Operating System (OS)
CSCI 351 – Mobile Applications Development
View-Controller Family
An Introduction to Computers and Visual Basic
What is UI Element in iPhone Development?
IOS App Development.
Office 2010 and Windows 7: Essential Concepts and Skills
EEC-492/693/793 iPhone Application Development
Fundamentals of Python: From First Programs Through Data Structures
Affordable iPhone Mobile Apps Development Services Company
EEC-492/693/793 iPhone Application Development
Microsoft Windows 2000 Professional
EEC-492/693/793 iPhone Application Development
Tutorial 6 Creating Dynamic Pages
CSC 581: Mobile App Development
Analysis models and design models
CSC 581: Mobile App Development
An Introduction to Computers and Visual Basic
Apple Xcode with Swift Demo
EEC-492/693/793 iPhone Application Development
Shelly Cashman: Microsoft Windows 10
CSC 581: Mobile App Development
UI Elements 2.
Presentation transcript:

iOS - First Application Anatomy Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283

Open Xcode from the /Applications directory The Xcode welcome window appears.

Create a new Xcode Project Choose a “Single View Application”

Provide details about your project

Review the Source Code

Review the Source Code #import <UIKit/UIKit.h> // // main.m // ToDo #import <UIKit/UIKit.h> #import "AppDelegate.h" int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); }

UIApplicationMain The call to UIApplicationMain creates two important initial components of your app: An instance of the UIApplication class, called the application object. The application object manages the app event loop and coordinates other high-level app behaviors. The UIApplication class, defined in the UIKit framework, doesn’t require you to write any additional code to get it to do its job. An instance of the AppDelegate class, called the app delegate. The app delegate creates the window where your app’s content is drawn and provides a place to respond to state transitions within the app. The app delegate is where you write your custom app-level code. Like all classes, the AppDelegate class is defined in two source code files in your app: in the interface file, AppDelegate.h, and in the implementation file, AppDelegate.m.

AppDelegate AppDelegate.h: The app delegate interface contains a single property: window. With this property the app delegate keeps track of the window in which all of your app content is drawn AppDelegate.m: The app delegate implementation contains “skeletons” of important methods. These predefined methods allow the application object to talk to the app delegate

App States State Description Not running The app has not been launched or was running but was terminated by the system. Inactive The app is running in the foreground but is currently not receiving events. (It may be executing other code though.) An app usually stays in this state only briefly as it transitions to a different state. Active The app is running in the foreground and is receiving events. This is the normal mode for foreground apps. Background The app is in the background and executing code. Most apps enter this state briefly on their way to being suspended. However, an app that requests extra execution time may remain in this state for a period of time. In addition, an app being launched directly into the background enters this state instead of the inactive state. For information about how to execute code while in the background, see Background Execution. Suspended The app is in the background but is not executing code. The system moves apps to this state automatically and does not notify them before doing so. While suspended, an app remains in memory but does not execute any code. When a low-memory condition occurs, the system may purge suspended apps without notice to make more space for the foreground app.

App States Most state transitions are accompanied by a corresponding call to the methods of your app delegate object. application:willFinishLaunchingWithOptions:—This method is your app’s first chance to execute code at launch time. application:didFinishLaunchingWithOptions:—This method allows you to perform any final initialization before your app is displayed to the user. applicationDidBecomeActive:—Lets your app know that it is about to become the foreground app. Use this method for any last minute preparation. applicationWillResignActive:—Lets you know that your app is transitioning away from being the foreground app. Use this method to put your app into a quiescent state. applicationDidEnterBackground:—Lets you know that your app is now running in the background and may be suspended at any time. applicationWillEnterForeground:—Lets you know that your app is moving out of the background and back into the foreground, but that it is not yet active. applicationWillTerminate:—Lets you know that your app is being terminated. This method is not called if your app is suspended.

UIViewController NSObject->UIResponder->UIViewController The UIViewController class provides the fundamental view-management model for all iOS apps A view controller manages a set of views that make up a portion of your app’s user interface A view controller is usually owned by a window or another view controller. If a view controller is owned by a window object, it acts as the window’s root view controller. The view controller’s root view is added as a subview of the window and resized to fill the window. If the view controller is owned by another view controller, then the parent view controller determines when and how the child view controller’s contents are displayed.

UIViewController NSObject->UIResponder->UIViewController The UIViewController class provides the fundamental view-management model for all iOS apps A view controller manages a set of views that make up a portion of your app’s user interface A view controller is usually owned by a window or another view controller. If a view controller is owned by a window object, it acts as the window’s root view controller. The view controller’s root view is added as a subview of the window and resized to fill the window. If the view controller is owned by another view controller, then the parent view controller determines when and how the child view controller’s contents are displayed.

UIViewController

UIViewController

Main.Storyboard A storyboard is a visual representation of the user interface of an iOS application, showing screens of content and the connections between those screens A storyboard is composed of a sequence of scenes, each of which represents a view controller and its views Each scene has at least a View Controller object, a First Responder object and an Exit Item

Storyboard Dock Canvas Inspector File Inspector Help Inspector Identity Inspector Attribute Inspector Size Inspector Connection Inspector

Storyboard Scene View Controller First Responder Exit It consist of the view that contains the screen The arrow pointing at the view controller from left indicates that it is initial view controller First Responder It is first in line for receiving many kinds of app events It receives key events, motion events, and action messages, among others Exit Unwind the scene and return back

Files: Anatomy Assets.xcassets: The assets catalog contains list of image sets. Each image set contains all version of an image that are necessary to support various devices and scale factors Info.plist: This file contains the setting for app Product/.app file: This is executable file for the app

Outlet An outlet provide a way to reference storyboard objects in view controller source files. It is a property that is annotated with the symbol IBOutlet To create an outlet, Control-drag from a particular object to a view controller file

Creating and Connecting an Outlet Steps With a storyboard open, choose View > Assistant Editor > Show Assistant Editor The implementation file(*.h) that corresponds to the storyboard opens in the assistant editor Control-drag from the object in storyboard to the header file in the assistant editor Xcode indicates where the new outlet is valid

Creating and Connecting an Outlet…

Creating and Connecting an Outlet… Release the Control-drag The assistant editor displays a Connection menu Choose Outlet from the Connection menu Type the name of the new outlet and click Connect

Action An action is some event that happens

Creating and Connecting an Action Same above steps change the connection type

UIButton Implements a button that intercepts touch events and sends an action message to a target object when it's tapped You can set the title, image, and other appearance properties of a button In addition, you can specify a different appearance for each button state.

UIButton… Common action Touch Up Inside Inspector window showing various properties

UIButton… A button sends the UIControlEventTouchUpInside event when the user taps it. You can respond to this event by performing some corresponding action in your app, such as saving information. You register the target-action methods for a button as shown below. [self.myButton addTarget:self action:@selector(myAction:) forControlEvents:UIControlEventValueChanged];

Labels Properties Creating Programatically NSObject->UIResponder->UIView->UILabel The UILabel class implements a read-only text view. Properties text textColor numberOfLines Creating Programatically UILabel *sLabel = [[UILabel alloc] initWithFrame:CGRectMake(20,300,100,60)] ;

Navigation One View to Another presentViewController offers a mechanism to display a so-called modal view controller; i.e., a view controller that will take full control of your UI by being superimposed on top of a presenting controller. presentViewController is an instance method of UIViewController Use [self presentViewController:vc2 animated:YES completion:NULL]; Use triggered Segue To finish the current View dismissViewControllerAnimated:YES completion:nil

UIViewController - Navigation //This will identify the Storyboard in use UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; //This will identify the View Controller to switch to SecondViewController *vc2 = [storyboard instantiateViewControllerWithIdentifier:@"SecondViewContr ollerID" ]; [self presentViewController:vc2 animated:YES completion:NULL];

Triggered Segue Segue represents a transition from one screen to another. Segues are triggered by taps on buttons, table view cells, gestures, and so on Passing Value Using Segue - (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender Get reference to destination View controller using method [segue destinationViewController] Then desired property of the destination view controller may be set.

Passing Data Back to Parent Class Get reference to the parent class [self presentingViewController] Set the desired data in parent view controller