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

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

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

ios Mobile Development

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

imso-104 Manual Revised August 5, 2011

SOFTWARE INSTRUCTIONS REAL-TIME STEERING ARRAY MICROPHONES AM-1B AM-1W

Tyler SIS Student 360 Mobile

Video Conference Classroom Documentation

imso-104 Manual Revised July 19, 2012

ecast for IOS Revision 1.3

Tyler SIS Student 360 Mobile

User Guide. Color Touchscreen Programmable Thermostat. ComfortSense Model: 13H /2017 Supersedes

VIBRIO. User Manual. by Toast Mobile

S P E C I A LT Y FEATURES USER GUIDE

Using different reference quantities in ArtemiS SUITE

Casambi App FAQ. Version Casambi Technologies Oy.

Spinner- an exercise in UI development. Spin a record Clicking

ECT 224: Digital Computer Fundamentals Digital Circuit Simulation & Timing Analysis

WaveLinx Mobile. WaveLinx Mobile Quick Start Guide. Programming Steps

Tyler SIS Student 360 Mobile

The New Contour INTRODUCING

We are here. Assembly Language. Processors Arithmetic Logic Units. Finite State Machines. Circuits Gates. Transistors

LEDBlinky Animation Editor Version 6.5 Created by Arzoo. Help Document

Lecture 12: State Machines

rio ision USER S GUIDE SPECIALTY FEATURES

Keyframing TOPICS. Camera Keyframing 'Key Camera' Popover Controlling the 'Key Camera' Transition Starting the 'Key Camera' Operation

Software Audio Console. Scene Tutorial. Introduction:

Smart Pianist Manual

Tyler SIS Student 360 Mobile

Thieme Dissector Manual

DALHOUSIE UNIVERSITY Department of Electrical & Computer Engineering Digital Circuits - ECED Experiment 2 - Arithmetic Elements

Instructions on IPTV Set-Top Box use to watch latvijas.tv broadcasts. Connecting the Set-Top box to Latvijas.tv

University of Pennsylvania Department of Electrical and Systems Engineering. Digital Design Laboratory. Lab8 Calculator

A Digital Talking Storybook

XYNTHESIZR User Guide 1.5

CE 9.2 Cisco TelePresence User Guide Systems Using Touch10

Cisco StadiumVision Defining Channels and Channel Guides in SV Director

USER MANUAL FOR DDT 2D. Introduction. Installation. Getting Started. Danley Design Tool 2d. Welcome to the Danley Design Tool 2D program.

About your Kobo ereader...6

ENGR 1000, Introduction to Engineering Design

VideoClock. Quick Start

ECE 301 Digital Electronics

There are three categories of unique transitions to choose from, all of which can be found on the Transitions tab:

A6 OPERATING INSTRUCTIONS

Dave Jones Design Phone: (607) Lake St., Owego, NY USA

Inspire Station. Programming Guide. Software Version 3.0. Rev A

Linkage 3.6. User s Guide

USER GUIDE V 1.6 ROLLERCHIMP DrumStudio User Guide page 1

Welcome to Fetch TV. Welcome to Fetch TV 3. Handy Tips 4. Watching Live TV 6. Using the TV Guide 8. Recording TV 10. Managing your Recordings 13

CE 9.1 Cisco TelePresence User Guide Systems Using Touch10

Lab experience 1: Introduction to LabView

AL37219C-EVB-A2 Evaluation Board

User Guide. MonitorMix User Guide 1

1. Material and RMA orders. 2. Send event to my outlook calendar. 3. Engineers allowed to see other engineers calendars (Read-only access)

Chapter 3 The Wall using the screen

Casambi App User Guide

Harmony Smart Control. User Guide

Polythemus AU Midi Effect for IOS User Manual (11 th Mar 2019)

KRAMER ELECTRONICS LTD. USER MANUAL

The Switcher: TriCaster 855 Extreme

Integer Chips. Explore Mode. In this tool, you can model and solve expressions using integer chips.


Cisco MX200/MX300/EX90 User Guide

XDFilt 1r0 July 23, XDFilt 1r0. Instructions. Copyright 2007, Steven A. Harlow 1

Room Guide Melbourne Campus 250 Victoria Parade Laser House Level 3

VISUAL MILL LAB. SECTION 1: Complete the following tests and fill out the appropriate sections on your Visual Mill Color Deficit Worksheet.

ISVClient. User Guide

Score Layout and Printing

V4.7 Software Quick Start Guide

Pre-processing of revolution speed data in ArtemiS SUITE 1

An Introduction to PHP. Slide 1 of :31:37 PM]

Formatting Dissertations or Theses for UMass Amherst with MacWord 2008

Amino. Digital Television. Sun City & Hilton Head Island

Handy Tips 4. Watching Live TV 6. Recording TV 10. Managing your Recordings 13. Watching Catch-Up TV on TV 17. Watching shows from the TV Store 18

Background. About automation subtracks

SmartScore Quick Tour

Room Guide Melbourne Campus 250 Victoria Parade Room 8.48 Provost

About your Kobo ereader...6

Bogart SE. User manual for version 4

Table of Contents Introduction

WELCOME TO THE NEW REHEARSCORE (APP)

Operating Instructions

GPS Rally Computer. Copyright 2017 MSYapps. All rights reserved. Manual for version 3.3.

WELCOME TO WURRLYedu

Quick Reference Guide to Switch Access to AAC Apps

CE 9.0 Cisco TelePresence User Guide Systems Using Touch10

TF5 / TF3 / TF1 DIGITAL MIXING CONSOLE. TF StageMix User's Guide

User's Guide. Version 2.3 July 10, VTelevision User's Guide. Page 1


Getting Started. Connect green audio output of SpikerBox/SpikerShield using green cable to your headphones input on iphone/ipad.

ComfortChoice Touch Thermostat. Designed for ZigBee R Wireless Technology USER GUIDE

Welcome to the U-verse App

Tutorial 11 ChipscopePro, ISE 10.1 and Xilinx Simulator on the Digilent Spartan-3E board

W A T C H. Using Your Remote Control. 145 N. Main Lenora, KS toll free

OPERATING MANUAL. including

Finding Multiples and Prime Numbers 1

III Phrase Sampler. User Manual

LS9 StageMix V6 User Guide

Cisco Spectrum Expert Software Overview

Smart Pianist V1.10. Audio demo songs User s Guide

Transcription:

Stanford Developing Applications for ios

Today Segues Modal Popover Unwind Embed

Modal View Controllers A way of segueing that takes over the screen Should be used with care. Example Contacts application. Tapping here adds a new contact. It does so by taking over the entire screen.

Modal View Controllers A way of segueing that takes over the screen Should be used with care. Example Contacts application. This is not a push. Notice, no back button (only Cancel).

Modal View Controllers A way of segueing that takes over the screen Should be used with care. Example Contacts application. Tapping here adds a photo to this contact. It also does so by taking over the entire screen.

Modal View Controllers A way of segueing that takes over the screen Should be used with care. Example Contacts application. Again, no back button.

Modal View Controllers A way of segueing that takes over the screen Should be used with care. Example Contacts application. Let s Cancel and see what happens.

Modal View Controllers A way of segueing that takes over the screen Should be used with care. Example Contacts application. We re back to the last Modal View Controller.

Modal View Controllers A way of segueing that takes over the screen Should be used with care. Example Contacts application. And Cancel again

Modal View Controllers A way of segueing that takes over the screen Should be used with care. Example Contacts application. Back to where we started.

Modal View Controllers Considerations The view controller we segue to using a Modal segue will take over the entire screen This can be rather disconcerting to the user, so use this carefully How do we set a Modal segue up? Just ctrl-drag from a button to another View Controller & pick segue type Modal If you need to present a Modal VC not from a button, use a manual segue func performsegue(withidentifier: String, sender: Any?) or, if you have the view controller itself (e.g. Alerts or from instantiateviewcontroller) func present(uiviewcontroller, animated: Bool, completion: (() -> Void)? = nil)

Modal View Controllers Preparing for a Modal segue You prepare for a Modal segue just like any other segue... func prepare(for: UIStoryboardSegue, sender: Any?) { } } if segue.identifier == GoToMyModalVC { let vc = segue.destination as MyModalVC // set up the vc to run here Hearing back from a Modally segued-to View Controller When the Modal View Controller is done, how does it communicate results back to presenter? If there s nothing to be said, just dismiss the segued-to MVC (next slide). To communicate results, generally you would Unwind (more on that in a moment).

Modal View Controllers How to dismiss a view controller The presenting view controller is responsible for dismissing (not the presented). You do this by sending the presenting view controller this message func dismiss(animated: Bool, completion: (() -> Void)? = nil) which will dismiss whatever MVC it has presented (if any). You can get at your presenting view controller with this UIViewController property var presentingviewcontroller: UIViewController? If you send this to a presented view controller, for convenience, it will forward to its presenter (unless it itself has presented an MVC, in which case it will dismiss that MVC). But to reduce confusion in your code, only send dismiss to the presenting controller. Unwind Segues (coming up soon) automatically dismiss (you needn t call the above method).

Modal View Controllers Controlling the appearance of the presented view controller In horizontally regular environments, this var determines what a presented VC looks like var modalpresentationstyle: UIModalPresentationStyle In addition to the default,.fullscreen, there s.overfullscreen (presenter visible behind) On ipad, if full screen is too much real estate, there s.formsheet and.pagesheet (these two use a smaller space and with a grayed out presenting view controller behind) In horizontally compact environments, these will all adapt to always be full screen! How is the modal view controller animated onto the screen? Depends on this property in the view controller that is being presented var modaltransitionstyle: UIModalTransitionStyle.coverVertical // slides the presented modal VC up from bottom of screen (the default).fliphorizontal // flips the presenting view controller over to show the presented modal VC.crossDissolve // presenting VC fades out as the presented VC fades in.partialcurl // only if presenting VC is full screen (& no more modal presentations coming) The presentation & transition styles can be set in the storyboard by inspecting the segue.

Demo Modal Segue Let s add an Inspector to our EmojiArt app. It will display the size and created date of the EmojiArt document.

Popover Popovers pop an entire MVC over the rest of the screen A Search for Appointment MVC

Popover Popovers pop an entire MVC over the rest of the screen Popover s arrow pointing to what caused it to appear

Popover Popovers pop an entire MVC over the rest of the screen The grayed out area here is inactive. Touching in it will dismiss the popover.

Popover A popover is almost exactly the same as a Modal segue You still ctrl-drag, you still have an identifier, you still get to prepare It just looks a little different (but it s still modal in that you can t do anything else) Things to note when preparing for a popover segue All segues are managed via a UIPresentationController (but we re not going to cover that) But we are going to talk about a popover s UIPopoverPresentationController It notes what caused the popover to appear (a bar button item or just a rectangle in a view) You can also control what direction the popover s arrow is allowed to point Or you can control how a popover adapts to different sizes classes (e.g. ipad vs iphone)

Popover Prepare Here s a prepare(for segue:) that prepares for a Popover segue func prepare(for segue: UIStoryboardSegue, sender: Any?) { } if let identifier = segue.identifier { } switch identifier { } case Do Something in a Popover Segue : if let vc = segue.destination as? MyController { if let ppc = vc.popoverpresentationcontroller { } } default: break ppc.permittedarrowdirections = UIPopoverArrowDirection.any ppc.delegate = self // more preparation here One thing that is different is that we are retrieving the popover s presentation controller

Popover Prepare Here s a prepare(for segue:) that prepares for a Popover segue func prepare(for segue: UIStoryboardSegue, sender: Any?) { } if let identifier = segue.identifier { } switch identifier { } case Do Something in a Popover Segue : if let vc = segue.destination as? MyController { if let ppc = vc.popoverpresentationcontroller { } } default: break ppc.permittedarrowdirections = UIPopoverArrowDirection.any ppc.delegate = self // more preparation here We can use it to set some properties that will control how the popover pops up

Popover Prepare Here s a prepare(for segue:) that prepares for a Popover segue func prepare(for segue: UIStoryboardSegue, sender: Any?) { } if let identifier = segue.identifier { } switch identifier { } case Do Something in a Popover Segue : if let vc = segue.destination as? MyController { if let ppc = vc.popoverpresentationcontroller { } } default: break ppc.permittedarrowdirections = UIPopoverArrowDirection.any ppc.delegate = self // more preparation here And we can control the presentation by setting ourself (the Controller) as the delegate

Popover Presentation Controller Adaptation to different size classes One very interesting thing is how a popover presentation can adapt to different size classes. When a popover is presenting itself in a horizontally compact environment (e.g. iphone), there might not be enough room to show a popover window comfortably, so by default it adapts and shows the MVC in full screen modal instead. But the popover presentation controller s delegate can control this adaptation behavior. Either by preventing it entirely func adaptivepresentationstyle( for controller: UIPresentationController, traitcollection: UITraitCollection ) -> UIModalPresentationStyle { } return UIModalPresentationStyle.none // do n t a dapt // the default in horizontally compact environments (iphone) is.fullscreen

Popover Presentation Controller Adaptation to different size classes One very interesting thing is how a popover presentation can adapt to different size classes. When a popover is presenting itself in a horizontally compact environment (e.g. iphone), there might not be enough room to show a popover window comfortably, so by default it adapts and shows the MVC in full screen modal instead. But the popover presentation controller s delegate can control this adaptation behavior. or by modifying the adaptation You can control the view controller that is used to present in the adapted environment Best example: wrapping a UINavigationController around the MVC that is presented func presentationcontroller(controller: UIPresentationController, { } viewcontrollerforadaptivepresentationstyle: UIModalPresentationStyle) -> UIViewController? // return a UIViewController to use (e.g. wrap a Navigation Controller around your MVC)

Popover Size Important Popover Issue: Size A popover will be made pretty large unless someone tells it otherwise. The MVC being presented knows best what it s preferred size inside a popover would be. It expresses that via this property in itself (i.e. in the Controller of the MVC being presented) var preferredcontentsize: CGSize The MVC is not guaranteed to be that size, but the system will try its best. You can set or override the var to always return an appropriate size.

Popover Segue Let s put our inspector into a popover. Demo

Unwind Segue The only segue that does NOT create a new MVC It can only segue to other MVCs that (directly or indirectly) presented the current MVC What s it good for? Jumping up the stack of cards in a navigation controller (other cards are considered presenters) Dismissing a Modally segued-to MVC while reporting information back to the presenter

How does it work? Unwind Segue Instead of ctrl-dragging to another MVC, you ctrl-drag to the Exit button in the same MVC

How does it work? Unwind Segue Instead of ctrl-dragging to another MVC, you ctrl-drag to the Exit button in the same MVC Then you can choose a special @IBAction method you ve created in another MVC

How does it work? Unwind Segue Instead of ctrl-dragging to another MVC, you ctrl-drag to the Exit button in the same MVC Then you can choose a special @IBAction method you ve created in another MVC This means segue by exiting me and finding a presenter who implements that method If no presenter (directly or indirectly) implements that method, the segue will not happen

Unwind Segue How does it work? Instead of ctrl-dragging to another MVC, you ctrl-drag to the Exit button in the same MVC Then you can choose a special @IBAction method you ve created in another MVC This means segue by exiting me and finding a presenter who implements that method If no presenter (directly or indirectly) implements that method, the segue will not happen This method must be marked @IBAction. And it must have a UIStoryboardSegue as its only argument.

How does it work? Unwind Segue If the @IBAction can be found, you (i.e. the presented MVC) will get to prepare as normal

How does it work? Unwind Segue If the @IBAction can be found, you (i.e. the presented MVC) will get to prepare as normal Then the special @IBAction will be called in the other MVC and that MVC will be shown on screen

How does it work? Unwind Segue If the @IBAction can be found, you (i.e. the presented MVC) will get to prepare as normal Then the special @IBAction will be called in the other MVC and that MVC will be shown on screen You will be dismissed in the process (i.e. you ll be unpresented and thrown away)

Demo Unwind Segue We re going to add a Close Document button to our inspector.

Embed Segue Putting a VC s self.view in another VC s view hierarchy! This can be a very powerful encapsulation technique. Xcode makes this easy Drag out a Container View from the object palette into the scene you want to embed it in. Automatically sets up an Embed Segue from container VC to the contained VC. Embed Segue Works just like other segues. prepare(for segue:, sender:), et. al.

Embed Segue Putting a VC s self.view in another VC s view hierarchy! This can be a very powerful encapsulation technique. Xcode makes this easy Drag out a Container View from the object palette into the scene you want to embed it in. Automatically sets up an Embed Segue from container VC to the contained VC. Embed Segue Works just like other segues. prepare(for segue:, sender:), et. al. View Loading Timing Don t forget, though, that just like other segued-to VCs, the embedded VC s outlets are not set at the time prepare(for segue:, sender:) is called. So often we will just grab a pointer to the embedded VC in prepare.

Demo Code Download the demo code from today s lecture.