douli4337 2014-08-11 01:39
浏览 31
已采纳

Titanium Studio / PHP - 在iOS上的webview中打开链接

I have a CodeIgniter system that can send messages to an app. The messages are sent as HTML and injected into a WebView in the app. However, on iOS, any links in the HTML cannot be clicked.

I've read that, for some reason, you have to manually add click event listeners to the links and call the fireEvent method with the url. If I want to do that, I'd have to modify the HTML before it is returned from the server. How can I scan through the HTML (as a string) and insert onClick attributes?

Or, is there a way to simply enable the app to open the links naturally, like Android does? At this stage it doesn't matter if they open in the WebView or Safari.

  • 写回答

1条回答 默认 最新

  • dougong8012 2014-08-11 04:26
    关注

    Try setting willHandleTouches:false on your WebView

    willHandleTouches : Boolean Explicitly specifies if this web view handles touches.

    On the iOS platform, if this web view or any of its parent views have touch listeners, the Titanium component intercepts all touch events. This prevents the user from interacting with the native web view components.

    Set this flag to false to disable the default behavior. Setting this property to false allows the user to interact with the native web view and still honor any touch events sent to its parents. No touch events will be generated when the user interacts with the web view itself.

    Set this flag to true if you want to receive touch events from the web view and the user does not need to interact with the web content directly.

    This flag is true by default to retain backwards compatibility with previous behavior.

    Default: true

    http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.UI.WebView-property-willHandleTouches

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?