Skip to content

Instantly share code, notes, and snippets.

@aryasurya21
Created June 21, 2020 10:22
Show Gist options
  • Save aryasurya21/261e6923e922d1080d2700cd5b6b6ede to your computer and use it in GitHub Desktop.
Save aryasurya21/261e6923e922d1080d2700cd5b6b6ede to your computer and use it in GitHub Desktop.
Final version of HomeViewController
import UIKit
class HomeViewController: UIViewController {
@IBOutlet weak var containerView: UIView!
private let checkInController: CheckInViewController
private let checkOutController: CheckOutViewController
init(){
self.checkInController = CheckInViewController()
self.checkOutController = CheckOutViewController()
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
}
private func switchContentController(_ destinationVC: UIViewController){
destinationVC.view.frame = CGRect(
x: 0,
y: 0,
width: self.containerView.frame.width,
height: self.containerView.frame.height
)
self.containerView.addSubview(destinationVC.view)
}
@IBAction func tappedCheckIn(_ sender: Any){
self.switchContentController(self.checkInController)
}
@IBAction func tappedCheckOut(_ sender: Any){
self.switchContentController(self.checkOutController)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment