Announcements. Today s Topics

Similar documents
Designing iphone Applications

Announcements. Today s Topics

Why Model-View-Controller?

View Controller Lifecycle

ios Mobile Development

View Controllers CPRE 388

Developing Applications for ios

Naviga&on and Tab Bar Controllers and Table View

The MVC Design Pattern

Mobile Computing. Overview. What is ios? 8/26/12. CSE 40814/60814 Fall 2012

Advanced ios. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 20 11/01/2012

Assignment III: Graphing Calculator

iphone Application Tutorial

Announcements. Lab 2 is due next Monday (Sept 25 th ) by 11:59 PM. Late policy is 10% of lab total per day late. So -7.5 points per day late for lab 2

CSE 438: Mobile Application Development Lab 2: Virtual Pet App

Assignment III: Graphing Calculator

Your First iphone OS Application

Your First iphone Application

Apple Development Technology Workshops

iphone App Basics iphone and ipod touch Development Fall 2009 Lecture 5

CS193P - Lecture 7. iphone Application Development. Navigation & Tab Bar Controllers

Announcements. Lab 3. Lab 2 is due on Monday Sept 21 st. Lab 3 is posted Due September 30 th

Building GUIs with UIKit. Kevin Cathey

ios DeCal : Lecture 2 Structure of ios Applications: MVC and Auto Layout

User Experience: Windows & Views

Storyboards and Controllers on OS X

My First iphone App. 1. Tutorial Overview

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016

Assignment III: Graphing Calculator

Announcement. Final Project Proposal Presentations and Updates

User Experience: Windows & Views

CS193P - Lecture 8. iphone Application Development. Scroll Views & Table Views

Data IAP 2010 iphonedev.csail.mit.edu edward benson / Thursday, January 14, 2010

OVERVIEW. Why learn ios programming? Share first-hand experience. Identify platform differences. Identify similarities with.net

ITP 342 Mobile App Development. Data Persistence

My First iphone App (for Xcode version 6.4)

Announcements. Today s Topics

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall

CS193E Lecture 7. Document-based Applications NSTableView Key-Value Coding

ITP 342 Advanced Mobile App Dev. Memory

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011

Navigation bar (Xcode version 4.5.2) 1. Create a new project. From the Xcode menu, select File > New > Project

Stanford CS193p. Developing Applications for ios. Spring Stanford CS193p. Spring 2012

Announcements. Paparazzi 3 assignment is due Wednesday 2/17 This Friday s extra session will feature Evan Doll

iphone Application Programming Lab 2: MVC and Delegation + A01 discussion

Stanford CS193p. Developing Applications for ios. Winter CS193p! Winter 2015

Assignment III: Graphing Calculator

Stanford CS193p. Developing Applications for ios Fall Stanford CS193p. Fall 2013

ITP 342 Mobile App Development. Data Persistence

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Fall Stanford CS193p Fall 2010

Widget Tour. iphone and ipod touch Development Fall 2009 Lecture 7

ios 101 Hands-On Challenges

epicurious Anatomy of an ios app Robert Tolar Haining June 25, 2010 ConvergeSE

Contents. iphone Training. Industry Trainers. Classroom Training Online Training ON-DEMAND Training. Read what you need

Object-Oriented Programming in Objective-C

Life Cycle. Chapter Explore the Game Application. Understanding the Views in a Game

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011

A Better MVC. 300 line view controllers or bust. Dave A guy who thinks too deeply about stuff

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011

Assignment I: Concentration

CS193P - Lecture 11. iphone Application Development. Text Input Presenting Content Modally

ios Application Development Course Details

INTRODUCTION TO ARCHITECTING YOUR IOS APP

CS193P - Lecture 10. iphone Application Development. Performance

Crea?ng Cloud Apps with Oracle Applica?on Builder Cloud Service

Today s Topics. Scroll views Table views. UITableViewController Table view cells. Displaying data Controlling appearance & behavior

SAMPLE CHAPTER. Brendan G. Lim Martin Conte Mac Donell MANNING

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017

CS193P: HelloPoly Walkthrough

CS193E Lecture #3 Categories and Protocols Cocoa Memory Management

iphone Programming Touch, Sound, and More! Norman McEntire Founder Servin Flashlight CodeTour TouchCount CodeTour

CS193p Spring 2010 Wednesday, March 31, 2010

Assignment I Walkthrough

iphone Programming Patrick H. Madden SUNY Binghamton Computer Science Department

Assignment II: Foundation Calculator

1 Build Your First App. The way to get started is to quit talking and begin doing. Walt Disney

Objectives. Submission. Register for an Apple account. Notes on Saving Projects. Xcode Shortcuts. CprE 388 Lab 1: Introduction to Xcode

CUSTOM VIEWS. The View Hierarchy. Chapter 12

lecture 8 & 9 Data Persistence + AVFoundation & Location

Mobile Application Development

Architecting ios Project. Massimo Oliviero

University of Texas at Arlington, TX, USA

CS193p Spring 2010 Monday, April 12, 2010

UICollectionView. NSCoder Milwaukee. 2 April John Psuik. Tuesday, April 2, 13

Document-Based App Programming Guide for Mac

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016

App SandBox Directory

ITP 342 Mobile App Development. Model View Controller

Key Value Observing (KVO) CPRE 388

Building an Application

Praktikum Entwicklung von Mediensystemen mit ios

UX & Usability Strategies and Website Assessments. Candice Kail, Web Services Librarian

Advanced Object- C Features

AUTO LAYOUT IS A UNICORN

Model-View-Controller Architecture

Assignment IV: Smashtag Mentions

Topics in Mobile Computing

Announcements. Lab 3 is due on Wednesday by 11:59 PM

View Concepts. iphone Application Programming Lecture 4: User Interface Design. SDK provide many types of Views to show your content

S A M P L E C H A P T E R

Transcription:

Announcements Lab 2 is due tonight Lab 3 is posted Due next Wednesday Sept 30 th 1 Extensible - CSE 436 Software Networking Engineering Platform Workshop 1 Today s Topics Designing iphone Applica;ons Model- View- Controller (Why and How?) View Controllers 2 Extensible - CSE 436 Software Networking Engineering Platform Workshop 2

Designing iphone Applica;ons 3 Extensible - CSE 436 Software Networking Engineering Platform Workshop 3 Two Flavors of Mail 4 Extensible - CSE 436 Software Networking Engineering Platform Workshop 4

Organizing Content 5 Extensible - CSE 436 Software Networking Engineering Platform Workshop 5 Organinzing Content Focus on your user s data One thing at a ;me Screenfuls of content 6 Extensible - CSE 436 Software Networking Engineering Platform Workshop 6

PaMerns for Organizing Content Naviga;on Bar Tab Bar 7 Extensible - CSE 436 Software Networking Engineering Platform Workshop 7 Naviga;on Bar Hierarchy of content Drill down into greater detail 8 Extensible - CSE 436 Software Networking Engineering Platform Workshop 8

Tab Bar Self- contained modes 9 Extensible - CSE 436 Software Networking Engineering Platform Workshop 9 A Screenful of Content Slice of your applica;on Views, data, logic 10 Extensible - CSE 436 Software Networking Engineering Platform Workshop 10

Parts of a Screenful 11 Extensible - CSE 436 Software Networking Engineering Platform Workshop 11 Parts of a Screenful 12 Extensible - CSE 436 Software Networking Engineering Platform Workshop 12

Model- View- Controller (Why and How?) 13 Extensible - CSE 436 Software Networking Engineering Platform Workshop 13 Why Model- View- Controller? Ever used the word spagher to describe code? Clear responsibili;es make things easier to maintain Avoid having one monster class that does everything 14 Extensible - CSE 436 Software Networking Engineering Platform Workshop 14

Why Model- View- Controller? Separa;ng responsibili;es also leads to reusability By minimizing dependencies, you can take a model or view class you ve already wrimen and use it elsewhere Think of ways to write fewer lines of code 15 Extensible - CSE 436 Software Networking Engineering Platform Workshop 15 Communica;on and MVC KVO, notifications KVO, notifications target-action, delegation 16 Extensible - CSE 436 Software Networking Engineering Platform Workshop 16

View Controllers 17 Extensible - CSE 436 Software Networking Engineering Platform Workshop 17 Problem: Managing a Screenful Controller manages views, data and applica;on logic Apps are made up of many of these Would be nice to have a well- defined star;ng point A la UIView for views Common language for talking about controllers 18 Extensible - CSE 436 Software Networking Engineering Platform Workshop 18

Problem: Building Typical Apps Some applica;on flows are very common NavigaFon- based Tab bar- based Combine the two Don t reinvent the wheel Plug individual screens together to build an app 19 Extensible - CSE 436 Software Networking Engineering Platform Workshop 19 UIViewController Basic building block Manages a screenful of content Subclass to add your applica;on logic View Controller 20 Extensible - CSE 436 Software Networking Engineering Platform Workshop 20

Your and Apple View Controllers Create your own UIViewController subclass for each screenful Plug them together using exis;ng composite view controllers 21 Extensible - CSE 436 Software Networking Engineering Platform Workshop 21 Your and Our View Controllers Create your own UIViewController subclass for each screenful Plug them together using exis;ng composite view controllers 22 Extensible - CSE 436 Software Networking Engineering Platform Workshop 22

#import <UIKit/UIKit.h> Your View Controller Subclass @interface MyViewController : UIViewController { // A view controller will usually // manage views and data NSMutableArray *mydata; UILabel *mylabel; } //Expose some of its contents to clients @property NSArray *mydata; // And respond to ac;ons - (IBAc;on) dosomeac;on:(id)sender; 23 Extensible - CSE 436 Software Networking Engineering Platform Workshop 23 The View in View Controller UIViewController superclass has a view property @property (retain) UIView *view; Loads lazily On demand when requested OS figures this out Can be purged on demand as well (low memory) Sizing and posi;oning the view? Depends on where it s being used Don t make assumpfons, be flexible 24 Extensible - CSE 436 Software Networking Engineering Platform Workshop 24

Don t do it! When to call - loadview? Cocoa tends to embrace a lazy philosophy Call - release instead of - dealloc Call - setneedsdisplay instead of - drawrect: Allows work to be deferred Performance! Consider Fme to launching an applicafon 25 Extensible - CSE 436 Software Networking Engineering Platform Workshop 25 Crea;ng Your View in Code Override - loadview Never call this directly Create your views Set the view property Create view controller with - init // Subclass of UIViewController - (void)loadview { MyView *myview = [[MyView alloc] initwithframe:frame]; self.view = myview; // The view controller now owns the view [myview release]; // With ARC we no longer need this } 26 Extensible - CSE 436 Software Networking Engineering Platform Workshop 26

Crea;ng Your View with Storyboard Lay out a view in Storyboard File s owner is view controller class 27 Extensible - CSE 436 Software Networking Engineering Platform Workshop 27 Crea;ng Your View with Storyboard Lay out a view Storyboard File s owner is view controller class Hook up view outlet Create view controller with - initwithnibname:bundle: 28 Extensible - CSE 436 Software Networking Engineering Platform Workshop 28

View Controller Lifecycle - (id)initwithnibname:(nsstring *)nibname bundle:(nsbundle *)bundle { if (self == [super init...]) { // Perform ini;al setup, nothing view- related mydata = [[NSMutableArray alloc] init]; self.;tle = @ Foo ; } return self; } 29 Extensible - CSE 436 Software Networking Engineering Platform Workshop 29 View Controller Lifecycle - (void)viewdidload { // Your view has been loaded // Customize it here if needed view.someweirdproperty = YES; } 30 Extensible - CSE 436 Software Networking Engineering Platform Workshop 30

View Controller Lifecycle - (void)viewwillappear:(bool)animated { [super viewwillappear:animated]; // Your view is about to show on the screen [self beginloadingdatafromtheweb]; [self startshowingloadingprogress]; } 31 Extensible - CSE 436 Software Networking Engineering Platform Workshop 31 View Controller Lifecycle - (void)viewwilldisappear:(bool)animated { [super viewwilldisappear:animated]; // Your view is about to leave the screen [self rememberscrollposi;on]; [self savedatatodisk]; } 32 Extensible - CSE 436 Software Networking Engineering Platform Workshop 32

Naviga;on View Controller Demo 33 Extensible - CSE 436 Software Networking Engineering Platform Workshop 33 34 Extensible - CSE 436 Software Networking Engineering Platform Workshop 34

Loading and Saving Data Lots of op;ons out there, depends on what you need NSUserDefaults Property lists SQLite Web services Covering in greater depth in a few weeks 35 Extensible - CSE 436 Software Networking Engineering Platform Workshop 35 Saving State Across App Launches NSUserDefaults to read and write prefs & state Singleton object: + (NSUserDefaults *)standarduserdefaults; Methods for storing & fetching common types: - (NSInteger)integerForKey:(NSString *)key; - (void)setinteger:(int)value forkey:(nsstring *)key; - (id)objectforkey:(nsstring *)key; - (void)setobject:(int)value forkey:(nsstring *)key; Find an appropriate ;me to store and restore your state 36 Extensible - CSE 436 Software Networking Engineering Platform Workshop 36

More View Controller Hooks Automa;cally rota;ng your user interface Low memory warnings 37 Extensible - CSE 436 Software Networking Engineering Platform Workshop 37 Suppor;ng Interface Rota;on - (BOOL)shouldAutorotateToInterfaceOrienta;on: (UIInterfaceOrienta;on)interfaceOrienta;on { } // This view controller only supports portraits return (interfaceorienta;on == UIInterfaceOrienta;onPortrait); 38 Extensible - CSE 436 Software Networking Engineering Platform Workshop 38

Suppor;ng Interface Rota;on - (BOOL)shouldAutorotateToInterfaceOrienta;on: (UIInterfaceOrienta;on)interfaceOrienta;on { } // This view controller supports all orienta;ons // except for upside- down. return (interfaceorienta;on!=uiinterfaceorienta;onportraitupsidedown); 39 Extensible - CSE 436 Software Networking Engineering Platform Workshop 39 Autoresizing Your Views view.autoresizingmask = UIViewAutoresizingFlexibleWidth UIViewAutoresizingFlexibleHeight; view.autoresizingmask = UIViewAutoresizingFlexibleWidth UIViewAutoresizingFlexibleTopMargin; 40 Extensible - CSE 436 Software Networking Engineering Platform Workshop 40

NSUserDefaults and Screen Orienta;on Demo 41 Extensible - CSE 436 Software Networking Engineering Platform Workshop 41 Lab 4 Demo 42 Extensible - CSE 436 Software Networking Engineering Platform Workshop 42

Final Projects 43 Extensible - CSE 436 Software Networking Engineering Platform Workshop 43