UIView带你锚定链接 [英] UIView that takes you to anchor link
问题描述
我正在开发一个iPhone应用程序,我将我的HTML内容作为HTMLString加载到UIWebview中,并希望有一个UIView告诉UIWebview滚动到锚链接。我可以从已加载的HTML内容滚动到锚点链接,或者我必须使用URL中的锚点链接重新加载页面吗?
I'm developing an iPhone app where I have my HTML content loaded in a UIWebview as a HTMLString and would like to have a UIView that tells the UIWebview to scroll to an anchor link. Can I scroll to the anchor link from the already loaded HTML content or I would have to reload the page with the anchor link in the URL?
谢谢,
fbr
推荐答案
这是一个完整的猜测,但也许你可以制作UIWebView使用Javascript滚动?
This is a complete guess, but perhaps you could make the UIWebView scroll with Javascript?
您可以使用此方法在UIWebView中执行Javascript
You can execute Javascript in your UIWebView with this method
- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
参见以编程方式滚动到锚标签,了解如何使用Javascript。
See Programmatically scroll to an Anchor Tag on how to use the Javascript.
这篇关于UIView带你锚定链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!