【问题标题】:Is it possible to launch iTunes from a page within a UIWebView?是否可以从 UIWebView 中的页面启动 iTunes?
【发布时间】:2012-07-25 21:58:57
【问题描述】:

我正在尝试让 iTunes 从加载在 UIWebView 中的 html 页面启动。

使用 Apple 文档中的示例

http://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Articles/iTunesLinks.html#//apple_ref/doc/uid/TP40007896-SW1

 <a
 href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewAlbum?i=156093464&id=156093462&s=143441">
 <img height="15" width="61" alt="Randy Newman - Toy Story
- You&#39;ve Got a Friend In Me" src="http://ax.phobos.apple.com.edgesuite.net/images/
 badgeitunes61x15dark.gif"></img> </a>

当我点击按钮 didFailLoadWithError: 将被调用WebKitErrorDomain 101

shouldStartLoadWithRequest: 对任何请求都返回 YES)

在浏览器中加载的相同 html 页面可以工作。


(该代码实际上还有另一个问题,请参阅此链接 Remote image doesn't get displayed in html page displayed in UIWebView

但是在改成这个之后它仍然不能在 UIWebView 中工作,但在浏览器中可以工作

  <a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewAlbum?i=156093464&id=156093462&s=143441">
      <img height="15" width="61" src="Btn_Go.png""></img>
  </a>

【问题讨论】:

  • 天哪,我笑shouldShartLoadWithRequest:的时间太长了。
  • 无论如何,你能发布你的按钮代码吗?

标签: ios uiwebview


【解决方案1】:

你会在this question找到你想要的。

答案使用-webView:shouldStartLoadWithRequest:navigationType和被点击链接的url scheme来判断链接是应该由系统打开还是在webview中打开。

它还会处理您提到的错误。 (但只能忽略它..)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-31
    • 1970-01-01
    相关资源
    最近更新 更多