Programmatically sending an app to background

前端 未结 4 1794

Is there a way to send the application to background? Similarly to how you can call XCUIApplication.terminate(), I have some UI Elements to test on applic

4条回答
  •  借酒劲吻你
    2020-12-10 05:06

    I just tried UIApplication.sharedApplication().performSelector("suspend") successfully.

    dispatch_after(2, dispatch_get_main_queue(), {       
        // suspend the app after two seconds
        UIApplication.sharedApplication().performSelector("suspend")
    })
    
    // Swift 4 version
    UIApplication.shared.perform(Selector("suspend"))
    

提交回复
热议问题