Mastering Interface Builder

34
Mastering Interface Builder — Or how to stop cursing and love IB — Dimitri Dupuis-Latour — @dupuislatour

Transcript of Mastering Interface Builder

Page 1: Mastering Interface Builder

Mastering Interface Builder— Or how to stop cursing and love IB —

Dimitri Dupuis-Latour — @dupuislatour

Page 2: Mastering Interface Builder

Once Upon a TimeA brief History of IB

Page 3: Mastering Interface Builder

Interface Builder1986

Page 4: Mastering Interface Builder

IB History A Brief Story of Time…

2001

Mac OS X

1986

NeXT

2008

iPhone SDK

Page 5: Mastering Interface Builder

Modern IB History A Dramatic Acceleration of Features

2011iOS 5

AutoLayout(OSX)Storyboards

Segue

2010iOS 4

Xcode IntegrationAll-in-one window

2014iOS 8

IBDesignableIBInspectableSize ClassesCustom FontsLocalisation

2013iOS 7

New AutoLayoutiOS7 makeoverAsset Catalogs

2012iOS 6

AutoLayout(iOS)

Page 6: Mastering Interface Builder

Don’t use IB like your Grandfather ! It’s 2015

Page 7: Mastering Interface Builder

AgendaStoryboards

TableView ControllersStatic TableViews

Unwind SegueCustom Segue Icon Font

Vector artworkSecret shortcuts

Page 8: Mastering Interface Builder

StoryboardsMore than just a meta XIB

Page 9: Mastering Interface Builder

Storyboard

Page 10: Mastering Interface Builder

Storyboard• Bird’s eye view • Visual way describe workflow • Communication Tool • Living Documentation

Page 11: Mastering Interface Builder

Not Approved

Page 12: Mastering Interface Builder

• Split by Feature / Tab / Unit of workflow (eg: Login, Creation)

Split Your Storyboards ! No « One Storyboard to Rule Them All »

// STORYBOARD - Instantiate from code let storyboard = UIStoryboard(name:"LoginScreens", bundle:nil) let vc = storyboard.instantiateViewControllerWithIdentifier("MyCustomVC")

as MyCustomVC

Page 13: Mastering Interface Builder

• Chain your screens in IB

• Takes out the simpler .push() .presentViewController(), didSelectRowAtIndexPath()

• Handle the more complex ones in - prepareForSegue: (iOS) - contextForSegue: (WatchKit, iOS 9 ?)

Build Navigation Hierarchy in IB

Page 14: Mastering Interface Builder

• Design / communication tool

• Split them

• Removes some push() / present() code

• best feature…

Storyboards : Recap More than just a meta XIB

Page 15: Mastering Interface Builder

Unwind SeguePush-pop-dismiss : sooo 2011

Page 16: Mastering Interface Builder

What are Unwind Segue ?

Auto-rewind to a specific screen

Page 17: Mastering Interface Builder

A B C D

E F GSubmit

navController.pop().pop() presentingController.dismiss() presentingController.navController.pop().pop().pop()

Problem 1: hardcoding Hierarchy in code

Page 18: Mastering Interface Builder

=> write custom @protocols => Store global variable / Singleton

Problem 2: passing data back to A

A B C D

E F GSubmit

Page 19: Mastering Interface Builder

A B C D

E F GSubmit

@IBAction func unwindTo### @IBAction func unwindToMyScreenA(segue: UIStoryboardSegue) {}

Step 1

Page 20: Mastering Interface Builder

A B C D

E F GSubmit

a) manually (eg: immediate action) b) programmatically (eg: deferred action)Step 2

@IBAction func unwindToMyScreenA(segue: UIStoryboardSegue) {}

Page 21: Mastering Interface Builder

A B C D

E F GSubmit

Step 2a - Manually

@IBAction func unwindToMyScreenA(segue: UIStoryboardSegue) {}

Page 22: Mastering Interface Builder

• Create a manual segue • ctrl-drag from File's Owner (VC) to Exit • choose Manual Segue • Select it in the outline view • Give it an Identifier "backToAPlease"

• Call it from Code

Step 2b - Programmatically

self.performSegueWithIdentifier("backToAPlease", sender:nil)

File's Owner Exit

Page 23: Mastering Interface Builder

• "Unwind" the navigation stack

• Including through push, modal, popover, tabs, etc…

• Passes data back (replacing custom @protocols)

• Less code

Unwind Segue : Recap

Page 24: Mastering Interface Builder

Custom SegueGo beyond push and modal

Page 25: Mastering Interface Builder

• Step 1) Select • Step 2) Set your class • Step 3) Enjoy !

Setup a Custom Segue

Page 26: Mastering Interface Builder

3DFlip Seguegithub.com/GlennChiu/

GC3DFlipTransitionStyleSegue

Page 27: Mastering Interface Builder

Fold Seguehttps://github.com/mpospese/

MPFoldTransition

Page 28: Mastering Interface Builder

DoorwaySeguegithub.com/jsmecham/DoorwaySegue

Page 29: Mastering Interface Builder

• Create your own transitions by subclassing UIStoryBoardSegue

• Componentize transistions in reusable blocks

• Share and reuse them !

Custom Segue : Recap Go beyond push & pop

Page 30: Mastering Interface Builder

One More ThingTip & Tricks

& Xcode 7 new features

Page 31: Mastering Interface Builder

Click Through Views

+ctrl + click⏏ shift

Page 32: Mastering Interface Builder

Measure distances

⌥alt + mouse over

Page 33: Mastering Interface Builder

🎉 Insert Emoji " Or any symbol really©★✔

+ctrl + space⌘ cmd

println("⛔ Found Error: ") println("⚠ Warning: ") println("✅ All Good: ")

Page 34: Mastering Interface Builder