The Controller in MVC of iOS CS4521. The controller in the MVC  Controller  Knows about model and view objects  The brains of the operation  Manages.

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

© 2011 Delmar, Cengage Learning Chapter 1 Getting Started with Dreamweaver.
Application Fundamentals Android Development. Announcements Posting in D2L Tutorials.
The First Program. Step 1  File->New Project Create a project named “HelloWorld”, and select View Based Application from the icons on the right.
Android 02: Activities David Meredith
Telerik Software Academy Mobile apps for iPhone & iPad.
The Accelerometer CSE 391 Fall 2011 Tony Scarlatos.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
View Controllers (second part) Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
Flowchart Start Input weight and height
CS6320 – MVC L. Grewe THE ISSUE: Separating Implementation from Interface The business logic stays the same regardless of what the presentation is The.
Suman B.K, iPhone Team Lead  Data Modelling  MVC-Design Patterns  Delegates & Notifications  Memory Management & Performance.
Session-01. Layers Struts 2 Framework The struts 2 framework is used to develop MVC-based web application. Struts 1.0 was released in June The.
Storyboards Managing multiple views. Overview Create a single view application Give the project a name and click “Use Storyboards” and “Use Automatic.
SCERSIG: Creating Android Apps with App Inventor 26 October 2011 Ric Paul, Health Services Library, Southampton.
Getting Started with Adobe Dreamweaver CS6. Unit Objectives Define web design software Start Adobe Dreamweaver CS6 View the Dreamweaver workspace Work.
Xcode Presentation Tom Pletzke. Creating App from template Launch Xcode Select Tabbed Application.
Java Beans.
Model View Controller (MVC) Rick Mercer with a wide variety of others 1.
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
Mobile Application Development using Android Lecture 2.
DUE Hello World on the Android Platform.
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
3461A Readings from the Swing Tutorial. 3461A Overview  The follow is the Table of Contents from the trail “Creating a GUI with JFC/Swing” in the “The.
1 Designing with a UIToolBar iPhone/iPad, iOS Development Tutorial.
SpotOn Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Object Oriented Software Development 9. Creating Graphical User Interfaces.
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.
Create a Web View App Step-by-Step. Step 1 Create a new project in XCode using the "Single View Application" option.
View Controllers Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
Chapter 38 Persistence Framework with Patterns 1CS6359 Fall 2011 John Cole.
C# GUI - Basics. Objectives.NET supports two types: WinForms, traditional, desktop GUI apps. WebForms – newer, for Web apps. Visual Studio.NET supports.
Gestures UIGestureRecognizer.
Passing data between storyboard views Singleton pattern.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Nav Controllers UINavigationController. Overview Nav Controller basics Like a tabview controller, a navViewController manages views A navigationViewController.
Topics Introduction Scene Graphs
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
User Interface Objects From Beginning iPhone 4 Development and The iPhone Developer’s Cookbook (Chapter 4)
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
March 9, 2009 Maze Solving GUI. March 9, 2009 MVC Model View Controller –Model is the application with no interfaces –View consists of graphical interfaces.
Chapter 1 Getting Started With Dreamweaver. Exploring the Dreamweaver Workspace The Dreamweaver workspace is where you can find all the tools to create.
ANDROID AND MODEL / VIEW / CONTROLLER. Slide 2 Design Patters Common solutions to programming problems are called design patterns Design patterns are.
The iOS Platform and SDK. iOS iPhoneiPad Mini iPad.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Building User Interfaces Basic Applications
Wes Preston DEV 202. Audience: Info Workers, Dev A deeper dive into use-cases where client-side rendering (CSR) and SharePoint’s JS Link property can.
WebViews UIWebView. Controller Architecture UITabBarController Controls the first view that the user sees The view controller class (and xib) that manages.
School of Engineering and Information and Communication Technology KIT305/KIT607 Mobile Application Development Android OS –Permissions (cont.), Fragments,
The Ingredients of Android Applications. A simple application in a process In a classical programming environment, the OS would load the program code.
INTRODUCTION TO ANDROID. Slide 2 Introduction I take a top-down approach to describing an application’s anatomy.
The Flag Quiz app tests your ability to correctly identify 10 flags from various countries and territories.
Views in iOS Mobile apps for iPhone & iPad Telerik Software Academy
Java FX: Scene Builder.
Mobile Application Development with MeeGo™ - Touch Apps & UI Design
Instructor: Mazhar Hussain
iOS - First Application Anatomy
Activities and Intents
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
Getting Started with Dreamweaver
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
Hands-on Introduction to Visual Basic .NET
CSC 581: Mobile App Development
CSC 581: Mobile App Development
Developing a Model-View-Controller Component for Joomla
Presentation transcript:

The Controller in MVC of iOS CS4521

The controller in the MVC  Controller  Knows about model and view objects  The brains of the operation  Manages relationships and data flow  Typically app-specific,  so rarely reusable

Visualization of the MVC for the “Contacts” App

Typical Application Flow  Some application flows are very common  Navigation-based  Tab bar-based  Combine the two Don’t reinvent the wheel Plug individual screens together to build an app

UIViewController  You will create as needed subclass of UIViewController MyViewController : UIViewController { // A view controller will usually // manage views and data NSMutableArray *myData; UILabel *myLabel; } //Expose data-content to users of this (readonly) NSArray *myData; // And respond to actions - (void)doSomeAction:(id)sender;

What does a UIViewController do? Where necessary, a view controller:  resizes and lays out its views  adjusts the contents of the views  acts on behalf of the views when the user interacts with them NOTE: this is MORE than handling user interaction A View Controller Controls a single “scene” (GUI if you will) and that means making it display as well as hooking up any user interaction code (event handling). A single scene has a root UIView that can contain a hierarchy of views

Where is the View in a UIViewController UIViewController superclass has a view property (retain) UIView *view; Loads lazily  On demand when requested  Can be son demand as well (low memory) NOTE: The view stored in this property represents the root view for the view controller’s view hierarchy

With Storyboarding on in your project –you can select which UIViewController displayed at launch  Select the UIViewController  In properties you can select it as the initial “scene”

Creating your own UIViewController subcalsses  Create your own UIViewController subclass for each screenful or View as needed  Plug them together using existing composite view controllers

UIViewController loading the View using nib file  initWithNibName method INSIDE your UIViewController class // The designated initializer. Override to perform setup that is required before the view is loaded. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { // Perform initialization --- NOTHING View related ******code here- don’t override method if nothing here } return self; }

Now we are not meant to edit our nib (.xib) files in raw XML (unlike other mobile platforms---android and.xml layout files)  BUT….. Here is a peak at PART of a simple “hello world” application with a UIView and a UILabel in it 274 YES 292 {{114, 74}, {89, 21}} NO YES 7 NO IBCocoaTouchFramework Hello World 1 MCAwIDAAA 1 10

UIViewController loading the View programmatically in loadView method // Implement loadView to create a view hierarchy programmatically, without using a nib. - (void)loadView { //create View object in code MyView *myView = [[MyView alloc] initWithFrame:frame]; //associate view object with this UIViewController’s view self.view = myView; // The view controller now owns the view [myView release]; }

View Lifecycle –what you must do in UIViewController  STEP 1: Create view using nib or programmatically  STEP 2: Implement viewDidLoad when you want to customize the view after it has been loaded in STEP 1 - (void)viewDidLoad { // Your view has been loaded // Customize it here if needed view.someWeirdProperty = YES; }  STEP 3: View about to appear –override if desired - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; // Your view is about to show on the screen [self beginLoadingDataFromTheWeb]; [self startShowingLoadingProgress]; }

View Lifecycle –what you must do in UIViewController  STEP 4: View about to DISAPPEAR –override if desired - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; // Your view is about to leave the screen [self rememberScrollPosition]; [self saveDataToDisk]; }