Skip to content

Commit

Permalink
Add view controller delegate methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Hyche committed Aug 11, 2017
1 parent 3654c32 commit 289b1ec
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
34 changes: 28 additions & 6 deletions LearnAboutSizeClasses/LearnAboutSizeClasses/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,25 @@

import UIKit

extension UIUserInterfaceSizeClass {
var debugText: String {
switch self {
case .compact: return "Compact"
case .regular: return "Regular"
case .unspecified: return "Unspecified"
}
}
}

extension UITraitCollection {

var debugText: String {
return "(H:\(horizontalSizeClass.debugText),V:\(verticalSizeClass.debugText))"
}
}

class ViewController: UIViewController {

@IBOutlet weak var stackView: UIStackView!
@IBOutlet weak var horizontalSizeClassLabel: UILabel!
@IBOutlet weak var verticalSizeClassLabel: UILabel!
@IBOutlet weak var compactWidthLabel: UILabel!
@IBOutlet weak var regularWidthLabel: UILabel!

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
Expand All @@ -26,6 +37,17 @@ class ViewController: UIViewController {
// Dispose of any resources that can be recreated.
}

override func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) {
print("Will Transition To Trait Collection \(newCollection.debugText)")
}

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
print("Will Transition to Size \(size)")
}

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
print("Trait Collection Did Change. New Trait Collection = \(traitCollection.debugText)")
}

}

0 comments on commit 289b1ec

Please sign in to comment.