2016-10-15 3 views
0

Ich fragte mich, ob jemand wusste, wie man einen Befehl ausführt, wenn der Benutzer die Home-Taste zweimal drückt und/oder wenn er nur drückt, um zum Home-Bildschirm zu gelangen. Snapchat tut dies, da es den Hintergrund verschwimmen, wenn Doppelklick auf einen View-Controller angezapft oder entlässt, wenn Sie gehen und in zurück.Wenn App Switcher erscheint, führe einen Befehl aus Xcode swift

Xcode 7.3.1 und wenn möglich könnte der Code Swift 2.2 oder 2.3

Dank sein Grüße,

Antwort

0

In Ihrem Appdelegate.swift Datei finden Sie zwei Methoden, die Sie Code, wenn Ihre Anwendung ändert sich von den Vordergrund ausführen lassen Zustand in den Hintergrund - wie Drücken der Home-Taste.

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 invalidate graphics rendering callbacks. Games should use this method to pause the game. 
} 

    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. 
} 
0

plz verwenden Ihre AppDelegate Methoden

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. 
    } 

    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. 
    } 
Verwandte Themen