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 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题