【发布时间】:2015-11-14 06:39:15
【问题描述】:
有什么方法可以在应用崩溃前截取屏幕截图。我正在使用此代码截屏,但如何知道应用程序何时崩溃?
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)
}
【问题讨论】:
-
在本机中,您可以为此使用测试用例,但您的问题是您需要屏幕截图,然后您需要进行一些第三方测试用例,这些图像和视频也会显示在哪里/发生崩溃时。
-
你不能。您可以安装异常处理程序,但它们非常有限。您最好的选择可能是有一个调试模式,您可以在其中不断保存图像或记录信息。当应用程序崩溃时,希望最后写的内容包含您需要的信息。
标签: ios iphone swift crash screenshot