Advanced-NSOperations/Earthquakes/SplitViewController.swift
2022-02-16 22:16:09 -08:00

30 lines
999 B
Swift
Raw 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 = .AllVisible
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
}
}