限制 UIScrollView 的最大速度?或者清除保存的图块渲染?
我有一个 UIScrollView,其中包含在平铺 UIWebView 中渲染的大量复杂矢量图形。
问题在于,当视图快速滚动(多次连续快速滑动)时,会出现难看的视觉故障,因为重复使用的图块在刷新之前包含旧渲染的快照。最终结果是,移出屏幕的图块似乎立即从另一侧返回,然后突然重新绘制其内容。
我希望有某种方法可以限制滚动视图可以轻弹的最大速度。我可以禁用轻拂滚动,但这并不理想。
如果有办法清除 UIWebView 保存的渲染,这也可能是一个很好的创可贴修复。
I have a UIScrollView with lots of complex vector graphics rendered in tiled UIWebViews.
The problem is that there are unsightly visual glitches when the view is scrolled quite quickly (several, consecutive quick swipes) because the reused tiles contain a snapshot of the old render before they get refreshed. The end result is that the tiles moving out of the screen appear to immediately come back in through the other side, before their contents are suddenly redrawn.
I'm hoping theres some way to limit the maximum speed that a scrollview can be flicked at. I could just disable flick scrolling, but that wouldn't be ideal.
If there's a way to clear the saved render of the UIWebView, that might also be a good band-aid fix.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案 1
在开始加载页面时隐藏 UIWebView,并在完成时通过 UIWebView 的委托显示它们 (
UIWebViewDelegate
)。在
webViewDidStartLoad:
隐藏 UIWebView(即myWebView.hidden = YES;
)。在webViewDidFinishLoad:
再次显示。在代码中的其他位置隐藏 webView 可能会更好,但在 webViewDidFinishLoad: 中显示它是一个好主意。您还需要滚动视图的背景,因为您将使用此方法看到 UIWebView 的后面。
解决方案 2
更改 UIScrollView 的
减速度
Solution 1
Hide the UIWebViews when they begin loading a page and show them when they finish via the UIWebView's delegate (
UIWebViewDelegate
).In
webViewDidStartLoad:
hide the UIWebView (i.e.myWebView.hidden = YES;
). InwebViewDidFinishLoad:
show it again.It may be better to hide the webView elsewhere in your code, but showing it in the webViewDidFinishLoad: is a good idea. You'll also want a background for the scrollview since you'll see behind the UIWebView's using this method.
Solution 2
Change the UIScrollView's
decelerationRate