Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CassiniViewController: UIViewController, UISplitViewControllerDelegate {
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do any additional setup after loading the view.
- }
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- // Dispose of any resources that can be recreated.
- }
- //22
- override func awakeFromNib() {
- super.awakeFromNib()
- self.splitViewController?.delegate = self
- }
- // MARK: - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
- // Get the new view controller using segue.destinationViewController.
- // Pass the selected object to the new view controller.
- //17
- if let url = DemoURL.NASA[segue.identifier ?? "" ] {
- //18.
- if let imageVC = (segue.destination.contents as? ImageViewController) {
- imageVC.imageURL = url
- imageVC.title = (sender as? UIButton)?.currentTitle
- }
- }
- }
- //23
- func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController: UIViewController, onto primaryViewController: UIViewController) -> Bool {
- if primaryViewController.contents == self {
- if let ivc = secondaryViewController.contents as? ImageViewController, ivc.imageURL == nil {
- return true
- }
- }
- return false
- }
- }
- //19.
- extension UIViewController {
- var contents: UIViewController {
- if let navcon = self as? UINavigationController {
- return navcon.visibleViewController ?? self
- } else {
- return self
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement