2015-05-14 139 views
0

我現在用的是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> 

,並顯示web視圖視圖是下列之一:

<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模擬器上,touch事件不起作用。點擊加載的頁面,沒有任何反應。

有什麼提示嗎?

+0

嘗試使用:https://github.com/viezel/NappDrawer – Jagu

回答

0

答案是willHandleToucheswebview屬性設置爲false。 來自官方文檔:

顯式指定此web視圖是否處理觸摸。 在iOS平臺上,如果此Web視圖或其任何父視圖具有觸摸偵聽器,那麼Titanium組件會截取所有觸摸事件。這可以防止用戶與原生Web視圖組件進行交互。 將此標誌設置爲false可禁用默認行爲。將此屬性設置爲false允許用戶與本機網絡視圖進行交互,並仍然尊重發送給其父母的任何觸摸事件。當用戶與網頁瀏覽本身交互時,不會產生任何觸摸事件。 如果您想從Web視圖接收觸摸事件,並且用戶不需要直接與Web內容交互,請將此標誌設置爲true。

所以

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

將正常工作。