Link from an HTML file to a view
I have an HTML file that's loaded from a UIWebView. I'm 开发者_JAVA百科looking to do the opposite - link from the HTML file to a different view controller. How would one go about doing this?
the html file is a local file within the app.
thanks for any help.
You can do this by adopting UIWebViewDelegate
protocol and implement the webView:shouldStartLoadWithRequest:navigationType:
method. Here you can capture all requests and selectively use them for your purpose.
Define links such as yourapp://yourviewcontroller/argument
within the HTML page and parse them in the above mentioned delegate method and load the appropriate view controller.
try using three20 library
https://github.com/facebook/three20
there is a helpful class for this named TTStyledText which render html as well as custom links. just need to map the links with ur controller. Go through the samples in three20!
Sorry for the short answer, but there are a lot of parts to this. Check out this link.
http://forums.macrumors.com/showthread.php?t=463491
It looks like you might have to register the url with Apple. I know that for the maps application its able to do urls like map://...
and I've seen other apps do it too, I just don't know the exact process.
Update: looks like this exampe from Apple should help.
精彩评论