Advanced-NSOperations/Earthquakes/SplitViewController.swift
2022-02-17 21:08:16 -08:00

30 lines
1,007 B
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
Copyright (C) 2015 Apple Inc. All Rights Reserved.
See LICENSE.txt for this samples licensing information
Abstract:
A UISplitViewController subclass that is its own delegate.
*/
import UIKit
class SplitViewController: UISplitViewController {
// MARK: Life Cycle
override func awakeFromNib() {
super.awakeFromNib()
preferredDisplayMode = .oneBesideSecondary
delegate = self
}
}
extension SplitViewController: UISplitViewControllerDelegate {
func splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController: UIViewController, ontoPrimaryViewController primaryViewController: UIViewController) -> Bool {
guard let navigation = secondaryViewController as? UINavigationController else { return false }
guard let detail = navigation.viewControllers.first as? EarthquakeTableViewController else { return false }
return detail.earthquake == nil
}
}