ios uistoryboard presentation
TRANSCRIPT
EXPERIENCES WITH STORYBOARDS
Gerald Kim - iOS Developer at jTribe@gerald_kim on Twitter
Monday, 22 July 13
- UIStoryboard introduced in iOS 5.0. An Interface Builder tool that encapsulates a viewcontroller graph
- Storyboards are an easy way to create a project quickly
- Nice way to see an entire project and how it's connected
Monday, 22 July 13
- UIStoryboard introduction. Still uses nibs when compiling- Can kind of use for wireframing. Rapidly make an app without codeImproving: Unwind segues in iOS 6
BASICS OF STORYBOARDS
• Storyboards are another tool to use. Code generated views and IB nibs can still fit in this toolbox as well
• Storyboard scenes are concerned with UIViewControllers
• Transitions between scenes dictated with UIStoryboardSegue
Monday, 22 July 13
Another tool. Can use blank viewcontrollers as container to represent a code or IB generated view.UIViewControllers only.
STORYBOARD SEGUES
• Built-in segues for the basic transitions: navigation push, modal, embed, pop-over (iPad only)
• Custom segues allow you to customize the transition, from animations to viewcontroller management
Monday, 22 July 13
Custom segues. Works with custom nav like popovers and hamburger slide menus like IIViewDeck. Personally found nothing custom segues couldn’t handle
STORYBOARD LIFECYCLE
• UIStoryboard will call initWithCoder: for you
• prepareForSegue: is called on source controller
• Storyboard loads its assets
• viewDidLoad: and the rest of the view methods are called
Monday, 22 July 13
- No more initWithFrame. Can't depend on designated initializers- Gives you a chance to respond to segue and pass information.[SHOW DEMO] of creating a segue and custom segue code, of prepareForSegue
STORYBOARDS AND COLLECTIONVIEWS
• Prototype cells can make layout easy
• Static cells great for menus
•Not as useful for reusable cells, especially with the new registerNib:forCellReuseIdentifier : and registerClass:forCellReuseIdentifier :
Monday, 22 July 13
- Prototype cells easy. Easier than before. Static tableviews [DEMO]- Not useful reuseable cells. Sharing cells between tableviews. Preferable to use nibs and code unless you want to copy/paste
STORYBOARDS AND CLUTTER
• Limit to how many scenes you can fit in a storyboard (I noticed sluggishness at around 30-40)
•Merge nightmare in a development team
• Copy/paste viewcontroller layouts for reuseable viewcontrollers
Monday, 22 July 13
Limit how many viewcontrollersMerge nightmare. Storyboards are still an ugly XML fileCopy/paste. eg Login or Gallery view that you want to show in multiple places. NEXT
STORYBOARD LINKING
• Can link Storyboards programmatically.+ (UIStoryboard *)storyboardWithName:bundle:- (id)instantiateInitialViewController
• RBStoryboardLinkhttps://github.com/rob-brown/RBStoryboardLink
Monday, 22 July 13
RBStoryboardLink. 3rd party library uses ViewController containment. Seperate storyboards into modules based on functionality. OK for some storyboards to contain 1 viewcontroller.
RBSTORYBOARDLINK
• RBStoryboardLink is a great way to visually see links
• Can continue to use segues during ‘links’
•Need to be careful of containment and new lifecycle
Monday, 22 July 13
Continue to use segues during links, looks nicer, more connectedCareful containment. Especially prepareForSegue, viewDidLoad in new controller[SHOW DEMO] Storyboard link, prepareForSegue to linked controller
WHEN NOT TO USE STORYBOARDS
• Custom views that don’t initially belong in the viewcontroller (keyboard accessory views)
• Reuseable views (UITableViewCells in multiple tableviews)
• Highly dynamic views
Monday, 22 July 13
Custom views. Keyboard accessory views, tableview headersReuseable views. Between viewcontrollers: Cells, etcHighly animated views. Need to add views dynamically
SHOULD I CONVERT TO STORYBOARDS?
• As always, it depends on your situation
• Easy Autolayout in XCode 5
•Need to convert app flow to prepareForSegue:
• UIAppearance proxies
•Definitely recommend new projects use UIStoryboard
Monday, 22 July 13
UIAppearance proxies: Apple swizzles init in views to implement appearance, overwriting any IB change. Will need to apply styles in viewDidLoad:
Questions?
• WWDC 2012 Session 407 - Adopting Storyboards into your App
• WWDC 2013 Session 405 - Interface Builder Core Concepts
REFERENCES
Monday, 22 July 13