ios - Webview 事件未触发

标签 ios webview titanium titanium-alloy

我正在使用 ds.slideMenu小部件,具有以下 View :

<Alloy>
<View id="containerview">
    <View id="leftMenu">
        <TableView id="leftTableView" />
    </View>
    <View id="movableview">
        <View id="shadowview">
            <View id="navview">
                <Button id="leftButton" />
            </View>
            <View id="contentview" />
        </View>
    </View>
</View>
</Alloy>

显示 webview 的 View 如下:

<Alloy>
<View class="container">
  <WebView id="webview" url="myremoteurlhere" onLoad="construct"/>
</View>
</Alloy>

介绍一下ds.slideMenu的代码是干什么的,下面是当你改变 View 时会发生什么:

function rowSelect(e) {
  if (Alloy.Globals.currentView.id != e.row.customView) {
    $.ds.contentview.remove(Alloy.Globals.currentView);
    currentView = Alloy.createController(e.row.customView).getView();
    currentView.touchEnabled = true;
    Alloy.Globals.currentView = currentView;
    $.ds.contentview.add(currentView);
  }
}

movableview 有一个用于“touchstart”、“touchend”、“touchmove”的 addEventListener 并且肯定会获取事件而不是我的 webview。现在,webview 加载没有问题,但在 iOS 模拟器上触摸事件不起作用。单击加载的页面,没有任何反应。

有什么提示吗?

最佳答案

答案是 willHandleTouches webview 属性设置为 false。 来自官方文档:

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.

所以

<WebView id="<mywebviewid>" willHandleTouches=false url="<myurlhere>"/>

将按预期工作。

关于ios - Webview 事件未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30232964/

相关文章:

javascript - iOS 停止随机发送 httprequests[Titanium]

javascript - Titanium appcellerator 上的句柄如何无法到达主机

javascript - 当两个 View 相交时如何添加事件监听器?

ios - iTunes connect - 无法添加新应用程序?

iphone - 从网络加载 UIImage 的最常见方式

ios - iPhone是否可以让用户从其内部对应用进行评分?

java - 授予互联网权限后 WebView 未加载?

java - 在 WebView 上将 EditText 与 loadUrl 组合

android - Webview 没有声音

ios - 辅助功能:如何始终将焦点设置在导航项的标题 View 上