AppDelegate.swift文件

记录下

//  AppDelegate.swift
//导入UIKit库
import UIKit
//当前app的入口点
@UIApplicationMain
//当前UIApplication的委托类,继承自UIResponder(响应用户的交互行为),实现协议UIApplicationDelegate
class AppDelegate: UIResponder, UIApplicationDelegate {
    //当前程序的窗口
    var window: UIWindow?

    //当前App夹在成功,调用这个
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        return true
    }
    //app在从当前激活状态变成不激活状态,调用这个方法,例如在app运行过程中接到电话
    func applicationWillResignActive(application: UIApplication) {
        // 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.
        // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    }
    //app进入到后台,调用这个方法,例如在app使用中按 home 键
    func applicationDidEnterBackground(application: UIApplication) {
        // 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.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }
    //从后台将要转入前台的时候调用,比如双击 home 键,单击 app 图标
    func applicationWillEnterForeground(application: UIApplication) {
        // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    }
    //本来在后台,现在即将转向前台,并且即将成为激活状态时调用
    func applicationDidBecomeActive(application: UIApplication) {
        // 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.
    }
    //程序退出的时候调用
    func applicationWillTerminate(application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }


}

标签: swift

添加新评论