iOS - 在应用程序崩溃前截取屏幕截图

标签 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)
}

最佳答案

AppDelegate:

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

关于iOS - 在应用程序崩溃前截取屏幕截图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33705853/

相关文章:

iphone - 从 UITableViewCell 中的详细信息公开按钮显示 UIPopoverController

ios - 如何访问和更改由 UIButton 组成的自定义 barButtonItem 的 NSAttributedString 标题?

iOS:为什么你不能在结构中有对象?

ios - 无法使用cordova访问iOS中的所有文件

纵向和横向 View 的 iOS Storyboard约束/特征

iphone - 代码错误 : No visible @interface for masterViewController declares the selector

iphone - 是否有流行的 iOS Twitter 客户端列表及其用于关注和发推文的自定义 URL 方案?

iphone - iOS 4.0 v 4.2 AdMob问题:尝试在ADBannerContentSizeIdentifierPortrait上的设备中断上运行

ios - 快速存储本地设置的最佳方法是什么?

xcode - 我可以用于 UILabel 的 swift 基本字体是什么