【发布时间】:2016-11-04 17:51:37
【问题描述】:
我正在使用以下代码来截取我的视图。
UIGraphicsBeginImageContext(self.view.bounds.size)
self.view.drawHierarchy(in: self.view.bounds, afterScreenUpdates: true)
let wholeImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
如果我将“afterScreenUpdates:”设置为 false,它可以正常工作。但如果我将其设置为 true,则会出现以下错误:
*** Assertion failure in -[UIApplication _performWithUICACommitStateSnapshotting:](), /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3600.5.2/UIApplication.m:6882
使用断点,我发现错误是在 drawHierarchy 方法上抛出的。以前有人见过这个错误吗?知道发生了什么吗?在获取快照之前,我尝试对视图进行任何更新(隐藏一些 uiimages),但它没有效果。
奇怪的附注:应用程序因此错误而冻结,但没有硬停止(我无法与调试器交互以查看回溯)。抱歉,如果不清楚。
【问题讨论】:
标签: ios swift uigraphicscontext