iOS - 在应用程序崩溃之前截屏

时间:2015-11-14 06:39:15

标签: ios iphone swift crash screenshot

有没有办法在应用程序崩溃之前截取屏幕截图。我使用此代码截取屏幕截图,但如何知道应用程序何时崩溃?

func screenShotMethod() {

    //Create the UIImage
    UIGraphicsBeginImageContext(view.frame.size)
    view.layer.renderInContext(UIGraphicsGetCurrentContext())
    let image = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()
    //Save it to the camera roll
    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
}

1 个答案:

答案 0 :(得分:1)

<强>的AppDelegate:

func applicationWillTerminate(application: UIApplication) {
    //that methiod is called when app is going to crash
}