未触发 Webview 事件
Webview events not fired
我正在使用 ds.slideMenu
小部件,它具有以下视图:
<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 的视图如下:
<Alloy>
<View class="container">
<WebView id="webview" url="myremoteurlhere" onLoad="construct"/>
</View>
</Alloy>
先介绍一下ds.slideMenu的代码是干什么的,下面是当你改变视图时会发生什么:
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 模拟器上触摸事件不起作用。点击加载页面,没有任何反应。
有什么提示吗?
答案是willHandleToucheswebview
属性设置为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>"/>
将按预期工作。
我正在使用 ds.slideMenu
小部件,它具有以下视图:
<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 的视图如下:
<Alloy>
<View class="container">
<WebView id="webview" url="myremoteurlhere" onLoad="construct"/>
</View>
</Alloy>
先介绍一下ds.slideMenu的代码是干什么的,下面是当你改变视图时会发生什么:
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 模拟器上触摸事件不起作用。点击加载页面,没有任何反应。
有什么提示吗?
答案是willHandleToucheswebview
属性设置为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>"/>
将按预期工作。