UIWebView:跟踪屏幕更新(脏区域)
我正在尝试检测 UIWebView 内发生的动画和其他屏幕更新。我想获取自上次刷新以来 UIWebView 中已修改的区域的矩形。
我认为我真正正在寻找的是一种“捕获”UIWebView 对 setNeedsDisplayInRect 进行的调用的方法。有办法做到这一点吗?我是否可以以某种方式子类化 UIWebView 的底层 CALayer 对象,从而允许我捕获来自 UIWebView 的这些调用?
I'm trying to detect animations and other screen updates as they happen inside a UIWebView. I would like to get the rectangles of areas in the UIWebView that have been modified since the last refresh.
I think really what I'm looking for is for a way to "trap" the calls that UIWebView makes to setNeedsDisplayInRect. Is there a way to do that? Can I somehow subclass UIWebView's underlying CALayer object in a way that would allow me to catch those calls as they come in from UIWebView?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有什么好的方法可以做到这一点。您可以尝试抓取 UIWebView 的 CALayer 的快照并将其与之前的快照进行比较,但我在获取可靠的 UIWebViews 快照方面遇到了很多麻烦。
There's no good way of doing that. You can try grabbing a snapshot of the UIWebView's CALayer and comparing it to the previous snapshot, but I've had a lot of trouble getting reliable snapshots of UIWebViews.
使用 Objective-C 类别 (@implementation CALayer (MyCALayer)) - 就像您已经根据更新所做的那样 - 捕获从 UIWebView 到 CALayer 的调用。
然后,使用 Method Swizzling 将类别覆盖中继到原始 CALayer 对象。
Use an Objective-C category (@implementation CALayer (MyCALayer)) - like you're already doing based on your update - to trap the calls going from UIWebView to CALayer.
Then, use Method Swizzling to relay your category overrides to the original CALayer object.