Debian Codegraph @

iOS/Csound iOS Swift Examples/Csound iOS SwiftExamples/AppDelegate.swift

raw
1 /*
2
3 AppDelegate.swift
4
5 Nikhil Singh, Dr. Richard Boulanger
6 Adapted from the Csound iOS Examples by Steven Yi and Victor Lazzarini
7
8 This file is part of Csound iOS SwiftExamples.
9
10 The Csound for iOS Library is free software; you can redistribute it
11 and/or modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
14
15 Csound is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public
21 License along with Csound; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 02111-1307 USA
24
25 */
26
27 import UIKit
28
29 @UIApplicationMain
30 class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate {
31
32 var window: UIWindow?
33 var splitViewController = UISplitViewController()
34
35 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
36 // Override point for customization after application launch.
37 splitViewController = window!.rootViewController as! UISplitViewController
38 let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController
39 navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem
40
41 splitViewController.delegate = navigationController.topViewController as! BaseCsoundViewController
42
43 return true
44 }
45
46 func applicationWillResignActive(_ application: UIApplication) {
47 // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
48 // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
49 }
50
51 func applicationDidEnterBackground(_ application: UIApplication) {
52 // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
53 // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
54 }
55
56 func applicationWillEnterForeground(_ application: UIApplication) {
57 // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
58 }
59
60 func applicationDidBecomeActive(_ application: UIApplication) {
61 // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
62 }
63
64 func applicationWillTerminate(_ application: UIApplication) {
65 // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
66 }
67
68 // MARK: - Split view
69
70 func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController:UIViewController, onto primaryViewController:UIViewController) -> Bool {
71 guard let secondaryAsNavController = secondaryViewController as? UINavigationController else { return false }
72 guard let topAsDetailController = secondaryAsNavController.topViewController as? BaseCsoundViewController else { return false }
73 if topAsDetailController.detailItem == nil {
74 // Return true to indicate that we have handled the collapse by doing nothing; the secondary controller will be discarded.
75 return true
76 }
77 return false
78 }
79 }
80