COMP327 Mobile Computing. Lecture Set 9 - Model, View, Controller

Size: px
Start display at page:

Download "COMP327 Mobile Computing. Lecture Set 9 - Model, View, Controller"

Transcription

1 COMP327 Mobile Computing Lecture Set 9 - Model, View, Controller 1

2 In this Lecture Set Anatomy of an Application Model View Controller Interface Builder and Nibs View Classes Views Drawing Text and Images 2

3 Anatomy of an Application An application is a bundle of files: Compiled code Your code Frameworks Nib files UI elements and other objects Details about object relationships Resources (images, sounds, strings, etc) Info.plist file (application configuration) Launch App App Initialised Load main nib Wait for an event Handle Event Exit App 3

4 UIKit Framework Provides standard interface elements UIKit and you Don t fight the frameworks Understand the designs and how you fit into them Starts your application Every application has a single instance of UIApplication Singleton design UIApplication + (UIApplication Orchestrates the lifecycle of an application Dispatches events Manages status bar, application icon badge Rarely subclassed Uses delegation instead Your instance of UIApplication. Good for querying the state of your app, etc 4

5 Delegation Control passed to delegate objects to perform application- specific behaviour Avoids need to subclass complex objects Many UIKit classes use delegates UIApplication UITableView UITextField UIApplicationDelegate Xcode project templates have one set up by default Object you provide that participates in application lifecycle Can implement various methods which UIApplication will call Examples: - (void)applicationdidfinishlaunching:(uiapplication *)application; - (void)applicationwillterminate:(uiapplication *)application; - (void)applicationwillresignactive:(uiapplication *)application; - (void)applicationdidreceivememorywarning:(uiapplication *)application; 5

6 Info.plist file Property List (often XML), describing your application i.e. your application configuration file Icon appearance Status bar style (default, black, hidden) Orientation (landscape vs portrait) Whether or not the app uses Wifi System Requirements Can edit most properties in Xcode Project > Edit Active Target Foo menu item On the properties tab 6

7 Model, View, Controller Glue-code (ish) connecting the model with the interface elements The underlying data and object model, and model algorithms, all being interface independent The interface components, and their dependency on each other 7

8 Model, View, Controller Model Your underlying data Manages the app data and state Not concerned with UI or presentation Often persists somewhere database or network store Same model should be reusable, unchanged in different interfaces iphone, cmd line, OSX app, etc 8

9 Model, View, Controller View What you see on the screen!!! Present the Model to the user in an appropriate interface Buttons, Sliders, Table-Views etc. Allows user to manipulate data Does not store any data (except to cache state) Easily reusable & configurable to display different data 9

10 Model, View, Controller Controller Glue that makes your app unique!!! Intermediary between Model & View Updates the view when the model changes Updates the model when the user manipulates the view Typically where the app logic lives. 10

11 Why use an MVC model? Ever used the word spaghetti to describe code? Clear responsibilities make things easier to maintain Avoid having one monster class that does everything Separating responsibilities also leads to reusability By minimising dependencies, you can take a model or view class you ve already written and use it elsewhere Think of ways to write less code 11

12 Model, View, Controller Controller outlets actions Model Object View (Interface) 12

13 Communication and MVC How should objects communicate? Which objects know about one another? Model Example: Person class Not aware of views or controllers Typically the most reusable Communicate generically using... Key-value observing Notifications 13

14 Communication and MVC How should objects communicate? Which objects know about one another? View Example: PersonView class Not aware of controllers, may be aware of relevant model objects Also tends to be reusable Communicate with controller using... Target-action Delegation 14

15 Communication and MVC How should objects communicate? Which objects know about one another? Controller Knows about model and view objects The brains of the operation Manages relationships and data flow Typically app-specific, so rarely reusable 15

16 Nib Files Helps you design the V in MVC: layout user interface elements add controller objects Connect the controller and UI At runtime, objects are unarchived Values/settings in Interface Builder are restored Ensures all outlets and actions are connected Order of unarchiving is not defined If loading the nib automatically creates objects and order is undefined, how do I customize? For example, to displaying initial state 16

17 Once the nib is loaded -awakefromnib Control point to implement any additional logic after nib loading Default empty implementation on NSObject You often implement it in your controller class e.g. to restore previously saved application state Guaranteed everything has been unarchived from nib, and all connections are made before -awakefromnib is called - (void)awakefromnib { } // do customisation here 17

18 Controls - Events View objects that allows users to initiate some type of action Respond to variety of events Touch events touchdown touchdragged (entered, exited, drag inside, drag outside) touchup (inside, outside) Value changed Editing events editing began editing changed editing ended 18

19 Controls - Target / Action When an event occurs, an action is invoked on the target object UIControlEventTouchUpInside target: action: event: UIControlEventTouchUpInside Method Call on the action selector: - (void) decrease) Controller (myobject) 19

20 Action Methods 3 different flavours of action method selector types (void)actionmethod; (void)actionmethod:(id)sender; (void)actionmethod:(id)sender withevent:(uievent *)event; UIEvent contains details about the event that took place Controls can trigger multiple actions on different targets in response to the same event Different than Cocoa on the desktop where only one targetaction is supported Different events can be setup in IB 20

21 Action Method Variations Simple no-argument selector - (void)increase { // bump the number of sides of the polygon up polygon.numberofsides += 1; } Single argument selector - control is sender // for example, if control is a slider... - (void)adjustnumberofsides:(id)sender { polygon.numberofsides = [sender value]; } 21

22 Action Method Variations Two-arguments in selector (sender & event) - (void)adjustnumberofsides:(id)sender withevent:(uievent *)event { // could inspect event object // if you needed to } 22

23 Manual Target-Action Same information the Interface Builder would use API and UIControlEvents found in UIControl.h UIControlEvents is a UIControl - (void)addtarget:(id)target action:(sel)action forcontrolevents:(uicontrolevents)controlevents; - (void)removetarget:(id)target action:(sel)action 23

24 View Fundamentals What is a View??? Rectangular area on screen Content can be drawn inside it Handles events A view is a subclass of UIResponder event handling class Views arranged hierarchically every view has one superview every view has zero or more subviews 24

25 View Hierarchy - UIWindow Views live inside of a window UIWindow is actually just a view adds some additional functionality specific to top level view One UIWindow for an iphone app Contains the entire view hierarchy Set up by default in Xcode template project 25

26 View Hierarchy - Manipulation Add/remove views: in Interface Builder, or using the following UIView methods: - (void)addsubview:(uiview *)view; - (void)removefromsuperview; Manipulate the view hierarchy manually: - (void)insertsubview:(uiview *)view atindex:(int)index; - (void)insertsubview:(uiview *)view belowsubview:(uiview *)view; - (void)insertsubview:(uiview *)view abovesubview:(uiview *)view; - (void)exchangesubviewatindex:(int)index withsubviewatindex:(int)otherindex; 26

27 View Hierarchy - Ownership Superviews retain their subviews Not uncommon for views to only be retained by superview Be careful when removing a view! It might have subviews you might want to keep! Retain subview before removing if you want to reuse it Views can be temporarily hidden theview.hidden = YES; 27

28 View Related Structures CGPoint location in space: { x, y } CGSize dimensions: { width, height } CGRect location and dimension: { origin, size } 28

29 Rects, Points, Sizes 29

30 View-related Structure Creation Function Example CGPointMake (x, y) CGPoint point = CGPointMake (100.0, 200.0); point.x = 300.0; point.y = 30.0; CGSizeMake (width, height) CGSize size = CGSizeMake (42.0, 11.0); size.width = 100.0; size.height = 72.0; CGRectMake (x, y, width, height) CGRect rect = CGRectMake (100.0, 200.0, 42.0, 11.0); rect.origin.x = 0.0; rect.size.width = 50.0; 30

31 UIView Coordinate Origin in upper left corner y axis grows downwards System 31

32 Location and Size View s location and size expressed in two ways Frame is in superview s coordinate system Bounds is in local coordinate system View A frame: origin: 0, 0 size: 550 x 400 View A bounds origin: 0, 0 size: 550 x 400 View B frame: origin: 200, 100 size: 200 x 250 View B bounds origin: 0, 0 size: 200 x

33 Frame and Bounds Which to use? Usually depends on the context If you are using a view, typically you use frame If you are implementing a view, typically you use bounds Matter of perspective From outside it s usually the frame From inside it s usually the bounds frame origin (200,100) (0,0) bounds origin Examples: Creating a view, positioning a view in superview - use frame Handling events, drawing a view - use bounds 33

34 Where do views come Two Options: from??? Programatically Views are initialised using -initwithframe: CGRect frame = CGRectMake(0, 0, 200, 150); UIView *myview = [[UIView alloc] initwithframe:frame]; Example: CGRect frame = CGRectMake(20, 45, 140, 21); UILabel *label = [[UILabel alloc] initwithframe:frame]; [window addsubview:label]; [label settext:@ Number of sides: ]; [label release]; // label now retained by window Interface Builder Drag out any of the existing view objects (buttons, labels, etc) Or drag generic UIView and set custom class 34

35 Defining Custom Views Subclass UIView For custom drawing, you override: - (void)drawrect:(cgrect)rect; For event handling, you override: - (void)touchesbegan:(nsset *)touches withevent:(uievent *)event; - (void)touchesmoved:(nsset *)touches withevent:(uievent *)event; - (void)touchesended:(nsset *)touches withevent:(uievent *)event; 35

36 Drawing Views - (void)drawrect:(cgrect)rect -[UIView drawrect:] does nothing by default If not overridden, then backgroundcolor is used to fill Override - drawrect: to draw a custom view rect argument is area to draw drawrect: is invoked automatically Don t call it directly! Let the framework decide When a view needs to be redrawn, use: - (void)setneedsdisplay; For example, in your controller: - (void)setnumberofsides:(int)sides { } numberofsides = sides; [polygonview setneedsdisplay]; Being lazy is good for performance. When the framework needs to render the views, it determines which are visible, and only draws those. For each view that should be redrawn, its drawrect method will be called. This can significantly improve performance!!! 36

37 CoreGraphics and Quartz 2D UIKit offers very basic drawing functionality UIRectFill(CGRect rect); UIRectFrame(CGRect rect); CoreGraphics - Drawing APIs CG is a C-based API, not Objective-C CG and Quartz 2D drawing engine define simple but powerful graphics primitives, including: Graphics context Transformations Paths Colours Fonts Painting operations 37

38 Graphics Context All drawing is done into an opaque graphics context Normally set up automatically, so no need to set this up explicitly Draws to screen, bitmap buffer, printer, PDF, etc. Graphics context setup automatically before invoking drawrect: Defines current path, line width, transform, etc. Access the graphics context within drawrect: by calling (CGContextRef)UIGraphicsGetCurrentContext(void); Use CG calls to change settings E.g. setting fill colour, line width, etc Context only valid for current call to drawrect: Do not cache a CGContext! 38

39 CG Wrappers Some CG functionality wrapped by UIKit UIColor Convenience for setting common colours Various predefined colours, but can also be created using RGB values etc... Easily set the fill and/or stroke colours when drawing UIColor *redcolor = [UIColor redcolor]; [redcolor set]; // drawing will be done in red UIFont Access system font Get font by name UIFont *font = [UIFont systemfontofsize:14.0]; [mylabel setfont:font]; 39

40 Simple drawrect: example Draw a solid colour and shape - (void)drawrect:(cgrect)rect { CGRect bounds = [self bounds]; [[UIColor graycolor] set]; UIRectFill (bounds); CGRect square = CGRectMake (10, 10, 50, 100); [[UIColor redcolor] set]; UIRectFill (square); } [[UIColor blackcolor] set]; UIRectFrame (square); 40

41 Drawing More Complex Shapes Common steps for drawrect: are 1. Get current graphics context 2. Define a path 3. Set a colour 4. Stroke or fill path Repeat, if necessary CoreGraphics paths define shapes Made up of lines, arcs, curves and rectangles Creation and drawing of paths are two distinct operations Define path first, then draw it 41

42 CGPath Two parallel sets of functions for using paths CGContext convenience throwaway functions Path actions occur immediately - one time only use CGPath functions for creating reusable paths A path is constructed, and then can be used/reused later CGContext CGContextMoveToPoint CGContextLineToPoint CGContextAddArcToPoint CGContextClosePath And so on and so on... CGPath CGPathMoveToPoint CGPathAddLineToPoint CGPathAddArcToPoint CGPathCloseSubPath 42

43 Simple Path Example - (void)drawrect:(cgrect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); [[UIColor graycolor] set]; UIRectFill ([self bounds]); CGContextBeginPath (context); CGContextMoveToPoint (context, 75, 10); CGContextAddLineToPoint (context, 10, 150); CGContextAddLineToPoint (context, 160, 150); CGContextClosePath (context); } [[UIColor redcolor] setfill]; [[UIColor blackcolor] setstroke]; CGContextDrawPath (context, kcgpathfillstroke); 43

44 UIImage UIKit class representing an image A variety of different image formats are supported Creating UIImages: Fetching image in application bundle (i.e. a resource) Use +[UIImage imagenamed:(nsstring *)name] Include file extension in file name, myimage.jpg Read from file on disk Use -[UIImage initwithcontentsoffile:(nsstring *)path] From data in memory Use -[UIImage initwithdata:(nsdata *)data] 44

45 Creating Images from a Context Need to dynamically generate a bitmap image Bitmap Image Example - (UIImage *)polygonimageofsize:(cgsize)size { Same as drawing a view General steps 1. Create a special CGGraphicsContext with a size 2. Draw 3. Capture the context as a bitmap 4. Clean up } UIImage *result = nil; UIGraphicsBeginImageContext (size); // call your drawing code... result = UIGraphicsGetImageFromCurrentContext(); UIGraphicsEndImageContext(); return result; 45

46 Getting Image Data Given UIImage, want PNG or JPG representation NSData *UIImagePNGRepresentation (UIImage * image); NSData *UIImageJPGRepresentation (UIImage * image); UIImage also has a CGImage property This will give you a CGImageRef to use with CG calls 46

47 Drawing Text and Images There are two ways: Drawing directly into the -drawrect Use other UIKit views You can draw UIImages in -drawrect: - [UIImage drawatpoint:(cgpoint)point] - [UIImage drawinrect:(cgrect)rect] - [UIImage drawaspatterninrect:(cgrect)rect] You can draw NSString in -drawrect: - [NSString drawatpoint:(cgpoint)point withfont:(uifont *)font] 47

48 Constructing Views How do I implement this? Goal PolygonView that displays shape as well as name Initial thought Have PolygonView draw the text Inefficient when animating Instead use UILabel! Add a UILabel as a subview of the PolygonView Gets all the benefits of the additional label classes Shadows, alignments etc 48

49 Other UIView Subclasses UILabel A UIView subclass that knows how to draw text Properties include: font textcolor shadow (offset & colour) textalignment (centre, adjustleft etc) UIImageView A UIView that draws UIImages Properties include: image animatedimages (can set up an array of images that create an animated image) animatedduration animatedrepeatcount contentmode (inherited from the UIView) A property to align and scale image with respect to bounds (e.g. centre, scale, fit, etc) 49

50 Other UIView Subclasses UIControl A UIView with Target-Action event handling Properties include: enabled selected highlighted UIButton: font, title, titlecolor, image, backgroundimage UITextField: font, text, placeholder, textcolor See UIKit headers for plenty more 50

51 To Recap... In this lecture set, we covered: The makeup of an application The Model / View / Controller design pattern Nib files Action Methods Views Coordinate Systems Frames and Bounds Drawing in Views Graphic Contexts Text, and Images 51

View Hierarchy - UIWindow

View Hierarchy - UIWindow Views and Drawing Views View Fundamentals Rectangular area on screen Draws content Handles events Subclass of UIResponder (event handling class) Views arranged hierarchically every view has one superview

More information

Today s Topics. Views Drawing Text & Images Animation

Today s Topics. Views Drawing Text & Images Animation Today s Topics Views Drawing Text & Images Animation 4 Views 5 View Fundamentals Rectangular area on screen Draws content Handles events Subclass of UIResponder (event handling class) Views arranged hierarchically

More information

Building an Application

Building an Application Building an Application 7 Anatomy of an Application Compiled code Your code Frameworks Nib files UI elements and other objects Details about object relationships Resources (images, sounds, strings, etc)

More information

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

Announcements. Lab 3. Lab 2 is due on Monday Sept 21 st. Lab 3 is posted Due September 30 th Announcements Lab 2 is due on Monday Sept 21 st Lab 3 is posted Due September 30 th 1 Extensible - CSE 436 Software Networking Engineering Platform Workshop 1 Lab 3 2 Extensible - CSE 436 Software Networking

More information

Monday, 1 November The ios System

Monday, 1 November The ios System The ios System System Overview System Overview System Overview System Overview System Overview System Overview Foundation Classes (Useful) Foundation Framework Value and collection classes User defaults

More information

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

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011 Developing Applications for ios Views A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space Draws and handles events in that rectangle Hierarchical A view has only one

More information

CS193p Spring 2010 Monday, April 12, 2010

CS193p Spring 2010 Monday, April 12, 2010 CS193p Spring 2010 Announcements Axess! Make sure your grading option matches what you were approved for Sonali s Office Hours Changed Friday 11am to 1pm Thursday 10am to noon Gates B26B Any questions

More information

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

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 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 Labs 3 and 4 are posted on the course website Extensible

More information

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

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Fall Stanford CS193p Fall 2010 Developing Applications for iphone 4, ipod Touch, & ipad Today One last Objective-C topic: Protocols Using protocols to define/implement/use a data source and/or delegate Views UIView and UIWindow classes

More information

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

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016 Stanford Developing Applications for ios Today Views Custom Drawing Demo FaceView Views A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space For drawing And for handling

More information

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

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017 Stanford Developing Applications for ios Today Views Custom Drawing Demo FaceView Views A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space For drawing And for handling

More information

Views. A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space

Views. A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space Views A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space Draws and handles events in that rectangle Hierarchical A view has only one superview - (UIView *)superview

More information

ios Mobile Development

ios Mobile Development ios Mobile Development Today Views How to draw custom stuff on screen. Gestures How to react to user s touch gestures. Demo SuperCard Views A view (i.e. UIView subclass) represents a rectangular area Defines

More information

Core Graphics & Animation. ios App Development Fall 2010 Lecture 17

Core Graphics & Animation. ios App Development Fall 2010 Lecture 17 Core Graphics & Animation ios App Development Fall 2010 Lecture 17 Questions? Announcements Assignment #5 out later this week Last of the short assignments Today s Topics Custom UIViews -drawrect: Core

More information

Custom Drawing & Animation. CS 442: Mobile App Development Michael Saelee

Custom Drawing & Animation. CS 442: Mobile App Development Michael Saelee Custom Drawing & Animation CS 442: Mobile App Development Michael Saelee 1 Frameworks - UIKit - Core Graphics / Quartz - Core Animation - OpenGL ES 2 UIKit OpenGL ES Core Graphics Core Animation

More information

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

Stanford CS193p. Developing Applications for ios. Winter CS193p! Winter 2015 Stanford CS193p Developing Applications for ios Today Objective-C Compatibility Bridging Property List NSUserDefaults Demo: var program in CalculatorBrain Views Custom Drawing Demo FaceView Bridging Objective-C

More information

Custom Drawing & Animation. CS 442: Mobile App Development Michael Saelee

Custom Drawing & Animation. CS 442: Mobile App Development Michael Saelee Custom Drawing & Animation CS 442: Mobile App Development Michael Saelee Frameworks - UIKit - Core Graphics / Quartz - Core Animation - OpenGL ES UIKit OpenGL ES Core Graphics Core Animation

More information

Designing iphone Applications

Designing iphone Applications Designing iphone Applications 4 Two Flavors of Mail 5 Organizing Content 6 Organizing Content 6 Organizing Content 6 Organizing Content 6 Organizing Content Focus on your user s data 6 Organizing Content

More information

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

View Concepts. iphone Application Programming Lecture 4: User Interface Design. SDK provide many types of Views to show your content View Concepts iphone Application Programming Lecture 4: User Interface Design SDK provide many types of Views to show your content At run-time Views are organized as a tree Chat Wacharamanotham Media Computing

More information

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

Stanford CS193p. Developing Applications for ios. Spring Stanford CS193p. Spring 2012 Developing Applications for ios Foundation Framework NSObject Base class for pretty much every object in the ios SDK Implements introspection methods, etc. - (NSString *)description is a useful method

More information

Developing Applications for ios

Developing Applications for ios Developing Applications for ios Lecture 4: Views, Autorotation and Gestures Radu Ionescu raducu.ionescu@gmail.com Faculty of Mathematics and Computer Science University of Bucharest Content Views Drawing

More information

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

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall Stanford Developing Applications for ios Today Miscellaneous Error Handling Any Other Interesting Classes Views Custom Drawing Demo: Draw a Playing Card enum Thrown Errors In Swift, methods can throw errors

More information

Views, Drawing, and Events. Lecture 5

Views, Drawing, and Events. Lecture 5 Views, Drawing, and Events Lecture 5 First - Representing Points and Areas NSPoint // Represents a point in a Cartesian coordinate system. typedef struct _NSPoint { CGFloat x; CGFloat y; } NSPoint Pair

More information

View Controller Lifecycle

View Controller Lifecycle View Controller Lifecycle View Controllers have a Lifecycle A sequence of messages is sent to them as they progress through it Why does this matter? You very commonly override these methods to do certain

More information

Graphics and Animation on ios

Graphics and Animation on ios Graphics and Animation on ios Graphics and Animation on ios Vandad Nahavandipoor Beijing Cambridge Farnham Köln Sebastopol Tokyo Graphics and Animation on ios by Vandad Nahavandipoor Copyright 2011 Vandad

More information

Custom Views and Events. Lecture 7

Custom Views and Events. Lecture 7 Custom Views and Events Lecture 7 First Representing Points and Areas NSPoint typedef struct _NSPoint { CGFloat x; CGFloat y; } NSPoint; Pair of x, y coordinates NSZeroPoint represents the bottom left

More information

lecture 10 UI/UX and Programmatic Design cs : spring 2018

lecture 10 UI/UX and Programmatic Design cs : spring 2018 lecture 10 UI/UX and Programmatic Design cs198-001 : spring 2018 1 Announcements custom app progress form due before lab (~1 minute) will be released after lecture only 2 labs left (both very important)

More information

CS193P: HelloPoly Walkthrough

CS193P: HelloPoly Walkthrough CS193P: HelloPoly Walkthrough Overview The goal of this walkthrough is to give you a fairly step by step path through building a simple Cocoa Touch application. You are encouraged to follow the walkthrough,

More information

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

CS193P - Lecture 8. iphone Application Development. Scroll Views & Table Views CS193P - Lecture 8 iphone Application Development Scroll Views & Table Views Announcements Presence 1 due tomorrow (4/28)! Questions? Presence 2 due next Tuesday (5/5) Announcements Enrolled students who

More information

User Experience: Windows & Views

User Experience: Windows & Views View Programming Guide for ios User Experience: Windows & Views 2010-07-07 Apple Inc. 2010 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or

More information

The MVC Design Pattern

The MVC Design Pattern The MVC Design Pattern The structure of iphone applications is based on the Model-View-Controller (MVC) design pattern because it benefits object-oriented programs in several ways. MVC based programs tend

More information

iphone Programming Patrick H. Madden SUNY Binghamton Computer Science Department

iphone Programming Patrick H. Madden SUNY Binghamton Computer Science Department iphone Programming Patrick H. Madden SUNY Binghamton Computer Science Department pmadden@acm.org http://optimal.cs.binghamton.edu General Outline Overview of the tools, and where to get more information

More information

Announcements. Today s Topics

Announcements. Today s Topics Announcements Lab 2 is due tonight by 11:59 PM Late policy is 10% of lab total per day late So -7.5 points per day late for lab 2 Labs 3 and 4 are posted on the course website Extensible Networking Platform

More information

Why Model-View-Controller?

Why Model-View-Controller? View Controllers Why Model-View-Controller? Ever used the word spaghetti to describe code? Clear responsibilities make things easier to maintain Avoid having one monster class that does everything Why

More information

Core Graphics and OpenGL ES. Dr. Sarah Abraham

Core Graphics and OpenGL ES. Dr. Sarah Abraham Core Graphics and OpenGL ES Dr. Sarah Abraham University of Texas at Austin CS329e Fall 2018 Core Graphics Apple s vector-drawing framework Previously known as Quartz or Quartz2D Includes handling for:

More information

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

iphone App Basics iphone and ipod touch Development Fall 2009 Lecture 5 iphone App Basics iphone and ipod touch Development Fall 2009 Lecture 5 Questions? Announcements Assignment #1 due this evening by 11:59pm Remember, if you wish to use a free late you must email me before

More information

Types of Views. View category Purpose Examples of views. Display a particular type of content, such as an image or text.

Types of Views. View category Purpose Examples of views. Display a particular type of content, such as an image or text. ios UI Components 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 Types of Views View

More information

Custom Views and Drawing. Lecture 5

Custom Views and Drawing. Lecture 5 Custom Views and Drawing Lecture 5 First - Representing Points and Areas NSPoint typedef struct _NSPoint { CGFloat x; CGFloat y; } NSPoint Pair of x, y coordinates NSZeroPoint represents the origin Create

More information

Announcements. Today s Topics

Announcements. Today s Topics 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-

More information

Developing Applications for ios

Developing Applications for ios Developing Applications for ios Lecture 5: Views, Drawing and Gestures Radu Ionescu raducu.ionescu@gmail.com Faculty of Mathematics and Computer Science University of Bucharest Content Views, Drawing and

More information

Objective-C Primer. iphone Programmer s Association. Lorenzo Swank September 10, 2008

Objective-C Primer. iphone Programmer s Association. Lorenzo Swank September 10, 2008 Objective-C Primer iphone Programmer s Association Lorenzo Swank September 10, 2008 Disclaimer Content was blatantly and unapologetically stolen from the WWDC 2007 Fundamentals of Cocoa session, as well

More information

iphone Application Programming Lecture 5: View Programming

iphone Application Programming Lecture 5: View Programming Lecture 5: View Programming Nur Al-huda Hamdan RWTH Aachen University Winter Semester 2015/2016 http://hci.rwth-aachen.de/iphone Name the UI Elements In the Screen 2 View Programming 3 View Programming

More information

Event Delivery: The Responder Chain

Event Delivery: The Responder Chain When you design your app, it s likely that you want to respond to events dynamically. For example, a touch can occur in many different objects onscreen, and you have to decide which object you want to

More information

CUSTOM VIEWS. The View Hierarchy. Chapter 12

CUSTOM VIEWS. The View Hierarchy. Chapter 12 Chapter 12 CUSTOM VIEWS A ll the visible objects in an application are either windows or views. In this chapter, you will create a subclass of NSView. From time to time, you will create a custom view to

More information

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

View Concepts. iphone Application Programming Lecture 4: User Interface Design. SDK provide many types of Views to show your content View Concepts iphone Application Programming Lecture 4: User Interface Design SDK provide many types of Views to show your content At run-time Views are organized as a tree Chat Wacharamanotham Media Computing

More information

Your First iphone OS Application

Your First iphone OS Application Your First iphone OS Application General 2010-03-15 Apple Inc. 2010 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form

More information

Building GUIs with UIKit. Kevin Cathey

Building GUIs with UIKit. Kevin Cathey Building GUIs with UIKit Kevin Cathey Building GUIs with UIKit acm.uiuc.edu/macwarriors/devphone Building GUIs with UIKit What is UIKit? acm.uiuc.edu/macwarriors/devphone Building GUIs with UIKit What

More information

Apple Development Technology Workshops

Apple Development Technology Workshops Apple Development Technology Workshops Workshop 10 Table Views Building iphone Apps. Pt 2 Fall 2008 Hafez Rouzati Fall 2008 Zach Pousman Last Week UIViewControllers Organizing Content & Building iphone

More information

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

CSE 438: Mobile Application Development Lab 2: Virtual Pet App CSE 438: Mobile Application Development Lab 2: Virtual Pet App Overview In this lab, you will create an app to take care of your very own virtual pets! The app will only have one screen and simple logic,

More information

iphone Application Tutorial

iphone Application Tutorial iphone Application Tutorial 2008-06-09 Apple Inc. 2008 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any

More information

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

iphone Programming Touch, Sound, and More! Norman McEntire Founder Servin Flashlight CodeTour TouchCount CodeTour iphone Programming Touch, Sound, and More! Norman McEntire Founder Servin 1 Legal Info iphone is a trademark of Apple Inc. Servin is a trademark of Servin Corporation 2 Welcome Welcome! Thank you! My promise

More information

Introduction to WatchKit. CS193W - Spring Lecture 1

Introduction to WatchKit. CS193W - Spring Lecture 1 Introduction to WatchKit CS193W - Spring 2016 - Lecture 1 appleᴡᴀᴛᴄʜ Released April 24, 2015 No updates to the hardware yet. Three collections, over 30 models Two sizes The Screen OLED (organic light-emitting

More information

CSC 581: Mobile App Development Spring 2018

CSC 581: Mobile App Development Spring 2018 CSC 581: Mobile App Development Spring 2018 Unit 2: Introduciton to the UIKit UIKit, UIViews UIControl subclasses 1 UIKit the UIKit is a code framework for building mobile apps the foundational class for

More information

ITP 342 Mobile App Dev. Interface Builder in Xcode

ITP 342 Mobile App Dev. Interface Builder in Xcode ITP 342 Mobile App Dev Interface Builder in Xcode New Project From the Main Menu, select the File à New à Project option For the template, make sure Application is selected under ios on the left-hand side

More information

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

OVERVIEW. Why learn ios programming? Share first-hand experience. Identify platform differences. Identify similarities with.net OVERVIEW Why learn ios programming? Share first-hand experience. Identify platform differences. Identify similarities with.net Microsoft MVP for 4 years C#, WinForms, WPF, Silverlight Joined Cynergy about

More information

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

Today s Topics. Scroll views Table views. UITableViewController Table view cells. Displaying data Controlling appearance & behavior Today s Topics Scroll views Table views Displaying data Controlling appearance & behavior UITableViewController Table view cells Scroll Views UIScrollView For displaying more content than can fit on the

More information

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

SAMPLE CHAPTER. Brendan G. Lim Martin Conte Mac Donell MANNING SAMPLE CHAPTER Brendan G. Lim Martin Conte Mac Donell MANNING ios 7 in Action by Brendan G. Lim Martin Conte Mac Donell Chapter 2 Copyright 2014 Manning Publications brief contents PART 1 BASICS AND NECESSITIES...1

More information

My First iphone App. 1. Tutorial Overview

My First iphone App. 1. Tutorial Overview My First iphone App 1. Tutorial Overview In this tutorial, you re going to create a very simple application on the iphone or ipod Touch. It has a text field, a label, and a button. You can type your name

More information

Assignment III: Graphing Calculator

Assignment III: Graphing Calculator Assignment III: Graphing Calculator Objective The goal of this assignment is to reuse your CalculatorBrain and CalculatorViewController objects to build a Graphing Calculator for iphone and ipad. By doing

More information

Mobile Application Programming. Controls

Mobile Application Programming. Controls Mobile Application Programming Controls Views UIView instances and subclasses Form a tree rooted at the window Have a backing store of pixels that are drawn seldomly, then composited to form the full user

More information

Your First iphone Application

Your First iphone Application Your First iphone Application General 2009-01-06 Apple Inc. 2009 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form

More information

Structuring an App Copyright 2013 Apple Inc. All Rights Reserved.

Structuring an App Copyright 2013 Apple Inc. All Rights Reserved. Structuring an App App Development Process (page 30) Designing a User Interface (page 36) Defining the Interaction (page 42) Tutorial: Storyboards (page 47) 29 App Development Process Although the task

More information

User Experience: Windows & Views

User Experience: Windows & Views View Controller Programming Guide for ios User Experience: Windows & Views 2011-01-07 Apple Inc. 2011 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval

More information

My First Cocoa Program

My First Cocoa Program My First Cocoa Program 1. Tutorial Overview In this tutorial, you re going to create a very simple Cocoa application for the Mac. Unlike a line-command program, a Cocoa program uses a graphical window

More information

Assignment III: Graphing Calculator

Assignment III: Graphing Calculator Assignment III: Graphing Calculator Objective The goal of this assignment is to reuse your CalculatorBrain and CalculatorViewController objects to build a Graphing Calculator. By doing this, you will gain

More information

Praktikum Entwicklung von Mediensystemen mit

Praktikum Entwicklung von Mediensystemen mit Praktikum Entwicklung von Mediensystemen mit Sommersemester 2013 Fabius Steinberger, Dr. Alexander De Luca Honors Degree in Technology Management at the Center for Digital Technology and Management (Barerstr.

More information

Apple introduced MapKit with ios, maps were based on Google.

Apple introduced MapKit with ios, maps were based on Google. History: Apple introduced MapKit with ios, maps were based on Google. With ios 6.0, Apple provided its own mapping service, which lacked some quality, especially level-of-detail. With ios 7 Apple opened

More information

TL;DR: Interface builder is the tool within Xcode for creating a User Interface via a GUI.

TL;DR: Interface builder is the tool within Xcode for creating a User Interface via a GUI. Week 8 Lab Comp327 week 8 lab for week commencing 12 November 2018. Interface Builder TL;DR: Interface builder is the tool within Xcode for creating a User Interface via a GUI. Interface Builder has been

More information

Mobile Application Programing: ios. Messaging

Mobile Application Programing: ios. Messaging Mobile Application Programing: ios Messaging Application Model View Controller (MVC) Application Controller User Action Update View Notify Update Model Messaging Controller User Action Update Notify Update

More information

ITP 342 Mobile App Development. Model View Controller

ITP 342 Mobile App Development. Model View Controller ITP 342 Mobile App Development Model View Controller Design Patterns A reusable pattern to solve common issues that come up in software development NOT new syntax, but the way you design your program What

More information

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

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall Stanford Developing Applications for ios Today Emoji Art Demo continued UITextField Editable text input control Demo: Add a text field to Emoji Art Demo Emoji Art Make our Emoji Art scrollable/zoomable/centered

More information

Lesson 1: Hello ios! 1

Lesson 1: Hello ios! 1 Contents Introduction xxv Lesson 1: Hello ios! 1 ios Developer Essentials 1 A Suitable Mac 1 A Device for Testing 2 Device Differences 2 An ios Developer Account 4 The Official ios SDK 6 The Typical App

More information

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

Contents. iphone Training. Industry Trainers. Classroom Training Online Training ON-DEMAND Training. Read what you need iphone Training Contents About iphone Training Our ios training classes can help you get off to a running start in iphone, ipod and ipad app development. Learn from expert Objective-C developers with years

More information

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

Advanced ios. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 20 11/01/2012 Advanced ios CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 20 11/01/2012 1 Goals of the Lecture Present a few additional topics and concepts related to ios programming persistence serialization

More information

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

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011 Developing Applications for ios Today UI Element of the Week UIToolbar ipad Split View Popover Universal (iphone + ipad) Application Demo Friday Section AVFoundation framework - Capturing and manipulating

More information

CS193p Spring 2010 Wednesday, March 31, 2010

CS193p Spring 2010 Wednesday, March 31, 2010 CS193p Spring 2010 Logistics Lectures Building 260 (History Corner) Room 034 Monday & Wednesday 4:15pm - 5:30pm Office Hours TBD Homework 7 Weekly Assignments Assigned on Wednesdays (often will be multiweek

More information

Assignment III: Graphing Calculator

Assignment III: Graphing Calculator Assignment III: Graphing Calculator Objective You will enhance your Calculator to create a graph of the program the user has entered which can be zoomed in on and panned around. Your app will now work

More information

Document-Based App Programming Guide for Mac

Document-Based App Programming Guide for Mac Document-Based App Programming Guide for Mac Contents About the Cocoa Document Architecture 7 At a Glance 7 The Model-View-Controller Pattern Is Basic to a Document-Based App 8 Xcode Supports Coding and

More information

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

Stanford CS193p. Developing Applications for ios. Winter CS193p! Winter 2015 Stanford CS193p Developing Applications for ios Today UITextField Bonus Topic! Table View A UIView for displaying long lists or tables of data UITextField Like UILabel, but editable Typing things in on

More information

let w = UIWindow(frame: UIScreen.mainScreen().bounds)

let w = UIWindow(frame: UIScreen.mainScreen().bounds) PART I Views The things that appear in your app s interface are, ultimately, views. A view is a unit of your app that knows how to draw itself. A view also knows how to sense that the user has touched

More information

Report Designer Report Types Table Report Multi-Column Report Label Report Parameterized Report Cross-Tab Report Drill-Down Report Chart with Static

Report Designer Report Types Table Report Multi-Column Report Label Report Parameterized Report Cross-Tab Report Drill-Down Report Chart with Static Table of Contents Report Designer Report Types Table Report Multi-Column Report Label Report Parameterized Report Cross-Tab Report Drill-Down Report Chart with Static Series Chart with Dynamic Series Master-Detail

More information

The Best of Both Worlds: Using UIKit with OpenGL

The Best of Both Worlds: Using UIKit with OpenGL The Best of Both Worlds: Using UIKit with OpenGL Noel Llopis Snappy Touch Twitter: @snappytouch About Me iphone development full time for a year and a half. Flower Garden on the app store. Interesting

More information

My First iphone App (for Xcode version 6.4)

My First iphone App (for Xcode version 6.4) My First iphone App (for Xcode version 6.4) 1. Tutorial Overview In this tutorial, you re going to create a very simple application on the iphone or ipod Touch. It has a text field, a label, and a button

More information

MVC and Interface Builder IAP 2010

MVC and Interface Builder IAP 2010 MVC and Interface Builder IAP 2010 iphonedev.csail.mit.edu edward benson / eob@csail.mit.edu Information-Driven Applications Application Flow UIApplication Main NIB Initialized UIAppDelegate - (void)applicationdidfinishlaunching:(uiapplication

More information

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

Objectives. Submission. Register for an Apple account. Notes on Saving Projects. Xcode Shortcuts. CprE 388 Lab 1: Introduction to Xcode Objectives Register for an Apple account Create an application using Xcode Test your application with the iphone simulator Import certificates for development Build your application to the device Expand

More information

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

epicurious Anatomy of an ios app Robert Tolar Haining June 25, 2010 ConvergeSE epicurious Anatomy of an ios app Robert Tolar Haining June 25, 2010 ConvergeSE + = Prototype iphone ipad Why iphone apps Simplicity Control Speed Revenue Epicurious Defined as a Recipe Utility Cookbook

More information

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

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall Stanford Developing Applications for ios Today Drag and Drop Transferring information around within and between apps. EmojiArt Demo Drag and drop an image to get our EmojiArt masterpieces started. UITableView

More information

Developing Applications for ios

Developing Applications for ios Developing Applications for ios Lecture 7: View Controller Lifecycle and UIKit Radu Ionescu raducu.ionescu@gmail.com Faculty of Mathematics and Computer Science University of Bucharest Content View Controller

More information

Learn to make desktop LE

Learn to make desktop LE HACKING WITH SWIFT COMPLETE TUTORIAL COURSE Learn to make desktop LE P apps with real-worldam S Swift projects REEPaul Hudson F Project 1 Storm Viewer Get started coding in Swift by making an image viewer

More information

ios Mobile Development

ios Mobile Development ios Mobile Development Today UITextView Scrollable, editable/selectable view of a mutable attributed string. View Controller Lifecycle Finding out what s happening as a VC is created, hooked up to the

More information

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

ios DeCal : Lecture 2 Structure of ios Applications: MVC and Auto Layout ios DeCal : Lecture 2 Structure of ios Applications: MVC and Auto Layout Overview : Today s Lecture Model View Controller Design Pattern Creating Views in Storyboard Connecting your Views to Code Auto

More information

ITP 342 Mobile App Development. Model View Controller

ITP 342 Mobile App Development. Model View Controller ITP 342 Mobile App Development Model View Controller Model-View-Controller The Model-View-Controller (MVC) design pattern assigns objects in an application one of three roles: model, view, or controller.

More information

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

CS193E Lecture 7. Document-based Applications NSTableView Key-Value Coding CS193E Lecture 7 Document-based Applications NSTableView Key-Value Coding Agenda Questions? Review: delegates, MVC Document-based apps Table views Key Value Coding Model, View, Controller Controller Model

More information

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

Widget Tour. iphone and ipod touch Development Fall 2009 Lecture 7 Widget Tour iphone and ipod touch Development Fall 2009 Lecture 7 Questions? Announcements Assignment #2 due Tonight by 11:59pm Today s Topics Controls Buttons Switches Sliders Segmented Controls Text

More information

Microsoft Office PowerPoint 2013 Courses 24 Hours

Microsoft Office PowerPoint 2013 Courses 24 Hours Microsoft Office PowerPoint 2013 Courses 24 Hours COURSE OUTLINES FOUNDATION LEVEL COURSE OUTLINE Using PowerPoint 2013 Opening PowerPoint 2013 Opening a Presentation Navigating between Slides Using the

More information

ios Memory Deep Dive #WWDC18 Kyle Howarth, Software Engineer James Snee, Software Engineer Kris Markel, Software Engineer

ios Memory Deep Dive #WWDC18 Kyle Howarth, Software Engineer James Snee, Software Engineer Kris Markel, Software Engineer Session #WWDC18 ios Memory Deep Dive 416 Kyle Howarth, Software Engineer James Snee, Software Engineer Kris Markel, Software Engineer 2018 Apple Inc. All rights reserved. Redistribution or public display

More information

Acollada ios Charting Components

Acollada ios Charting Components Acollada ios Charting Components Acollada ios Charting Components... 1 LineChartView... 3 Description... 3 Screenshot... 3 Protocols to be implemented... 3 Customizing the LineChartView aspect... 4 How

More information

AVAudioPlayer. avtouch Application

AVAudioPlayer. avtouch Application AVAudioPlayer avtouch Application iphone Application Index 1. iphone Application 1) iphone Application 2) iphone Application Main Method 3) iphone Application nib(.xib) 2. avtouch Application 1) avtouch

More information

How to...create a Video VBOX Gauge in Inkscape. So you want to create your own gauge? How about a transparent background for those text elements?

How to...create a Video VBOX Gauge in Inkscape. So you want to create your own gauge? How about a transparent background for those text elements? BASIC GAUGE CREATION The Video VBox setup software is capable of using many different image formats for gauge backgrounds, static images, or logos, including Bitmaps, JPEGs, or PNG s. When the software

More information

Assignment I Walkthrough

Assignment I Walkthrough Assignment I Walkthrough Objective Reproduce the demonstration (building a calculator) given in class. Materials By this point, you should have been sent an invitation to your sunet e-mail to join the

More information