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

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

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!