responsive ios collection views
TRANSCRIPT
Year 2010if UI_USER_INTERFACE_IDIOM() == .Pad { // iPad layout code here}else { // iPhone layout code here}
CGSizeMake(1024, 768)UIScreen.mainScreen().bounds.size// What about interface orientation?
if UI_USER_INTERFACE_IDIOM() == .Pad { // iPad layout code here}else { // iPhone layout code here}
CGSizeMake(1024, 768)UIScreen.mainScreen().bounds.size// What about interface orientation?
Year 2010
if UI_USER_INTERFACE_IDIOM() == .Pad { // iPad layout code here}else { // iPhone layout code here}
CGSizeMake(1024, 768)UIScreen.mainScreen().bounds.size// What about interface orientation?
Year 2010
if UI_USER_INTERFACE_IDIOM() == .Pad { // iPad layout code here}else { // iPhone layout code here}
CGSizeMake(1024, 768)UIScreen.mainScreen().bounds.size// What about interface orientation?
Year 2010
😱
if UI_USER_INTERFACE_IDIOM() == .Pad { // iPad layout code here}else { // iPhone layout code here}
Bad
if UI_USER_INTERFACE_IDIOM() == .Pad { // iPad layout code here}else { // iPhone layout code here}
Bad
if UI_USER_INTERFACE_IDIOM() == .Pad { // iPad layout code here}else { // iPhone layout code here}
// in your view controller:let traitCollection: UITraitCollection = self.traitCollectionswitch traitCollection.horizontalSizeClass { case .Regular: // do this case .Compact: // do that case .Unspecified: // look this up: https://dayone.me/uJGzoW}switch traitCollection.verticalSizeClass {// same thing}// What about interface orientation?
Bad
Good
UI_USER_INTERFACE_IDIOM() UITraitCollection
Changes Neverat runtime
(interface rotation,split view updates)
Scope Everywhere(it’s a macro) UIViewController
func traitCollectionDidChange(previousTraitCollection: UITraitCollection?)
Responsive Collection Views
• Case Study: the iOS Photos app
• Compact layout and Regular layout are quite different
Summary• Universal apps: think ahead (even if PO tells you MVP is iPhone or iPad
only)
• Bonus: teach responsive layouts to designers
• Don’t: UI_USER_INTERFACE_IDIOM()
• Do: Size Classes & UITraitCollections
• You will get split view support for free
• Your app will work on new screen sizes
• Do your layouts in IB, only resort to code you can’t do it in IB
• If you can: use Stack Views
• WWDC….
(Personal opinion)
Summary• Universal apps: think ahead (even if PO tells you MVP is iPhone or iPad
only)
• Bonus: teach responsive layouts to designers
• Don’t: UI_USER_INTERFACE_IDIOM()
• Do: Size Classes & UITraitCollections
• You will get split view support for free
• Your app will work on new screen sizes
• Do your layouts in IB, only resort to code you can’t do it in IB
• If you can: use Stack Views
• WWDC….
(Personal opinion)
Summary• Universal apps: think ahead (even if PO tells you MVP is iPhone or iPad
only)
• Bonus: teach responsive layouts to designers
• Don’t: UI_USER_INTERFACE_IDIOM()
• Do: Size Classes & UITraitCollections
• You will get split view support for free
• Your app will work on new screen sizes
• Do your layouts in IB, only resort to code you can’t do it in IB
• If you can: use Stack Views
• WWDC….
(Personal opinion)
Summary• Universal apps: think ahead (even if PO tells you MVP is iPhone or iPad
only)
• Bonus: teach responsive layouts to designers
• Don’t: UI_USER_INTERFACE_IDIOM()
• Do: Size Classes & UITraitCollections
• You will get split view support for free
• Your app will work on new screen sizes
• Do your layouts in IB, only resort to code you can’t do it in IB
• If you can: use Stack Views
• WWDC….
(Personal opinion)
Summary• Universal apps: think ahead (even if PO tells you MVP is iPhone or iPad
only)
• Bonus: teach responsive layouts to designers
• Don’t: UI_USER_INTERFACE_IDIOM()
• Do: Size Classes & UITraitCollections
• You will get split view support for free
• Your app will work on new screen sizes
• Do your layouts in IB, only resort to code you can’t do it in IB
• If you can: use Stack Views
• WWDC….
(Personal opinion)
Summary• Universal apps: think ahead (even if PO tells you MVP is iPhone or iPad
only)
• Bonus: teach responsive layouts to designers
• Don’t: UI_USER_INTERFACE_IDIOM()
• Do: Size Classes & UITraitCollections
• You will get split view support for free 💪👏😃
• Your app will work on new screen sizes
• Do your layouts in IB, only resort to code you can’t do it in IB
• If you can: use Stack Views
• WWDC….
(Personal opinion)
Summary• Universal apps: think ahead (even if PO tells you MVP is iPhone or iPad
only)
• Bonus: teach responsive layouts to designers
• Don’t: UI_USER_INTERFACE_IDIOM()
• Do: Size Classes & UITraitCollections
• You will get split view support for free 💪👏😃
• Your app will work on new screen sizes
• Do your layouts in IB, only resort to code you can’t do it in IB
• If you can: use Stack Views
• WWDC….
(Personal opinion)
Summary• Universal apps: think ahead (even if PO tells you MVP is iPhone or iPad
only)
• Bonus: teach responsive layouts to designers
• Don’t: UI_USER_INTERFACE_IDIOM()
• Do: Size Classes & UITraitCollections
• You will get split view support for free 💪👏😃
• Your app will work on new screen sizes
• Do your layouts in IB, only resort to code you can’t do it in IB
• If you can: use Stack Views
• WWDC….
(Personal opinion)
Summary• Universal apps: think ahead (even if PO tells you MVP is iPhone or iPad
only)
• Bonus: teach responsive layouts to designers
• Don’t: UI_USER_INTERFACE_IDIOM()
• Do: Size Classes & UITraitCollections
• You will get split view support for free 💪👏😃
• Your app will work on new screen sizes
• Do your layouts in IB, only resort to code you can’t do it in IB
• If you can: use Stack Views
• WWDC….
(Personal opinion)
Summary• Universal apps: think ahead (even if PO tells you MVP is iPhone or iPad
only)
• Bonus: teach responsive layouts to designers
• Don’t: UI_USER_INTERFACE_IDIOM()
• Do: Size Classes & UITraitCollections
• You will get split view support for free 💪👏😃
• Your app will work on new screen sizes
• Do your layouts in IB, only resort to code you can’t do it in IB
• If you can: use Stack Views
• WWDC….
(Personal opinion)
Thank Youhttps://github.com/bizz84/ResponsiveCollectionViews
Twitter: @biz84
blog: http://bizz84.github.io/