2013-10-30 65 views
-3

我知道如何在鈦中創建和設置iOS刷新按鈕,但我不知道如何使它們實際刷新標籤頁/窗口中的數據。我爲我的app.js和其他四個選項卡創建了刷新按鈕,但它不刷新數據。在鈦中創建並設置ios刷新按鈕

var Cloud = require('ti.cloud'); 


var scrollView4 = Ti.UI.createScrollView({ 
    contentWidth: 'auto', 
    contentHeight: 'auto', 
    showVerticalScrollIndicator: true, 
    showHorizontalScrollIndicator: true 
}); 
Titanium.UI.currentWindow.add(scrollView4); 
var currentWin4 = Titanium.UI.currentWindow; 





var refreshBtn = Titanium.UI.createButton({ 
    Color: 'black', 
    systemButton : Titanium.UI.iPhone.SystemButton.REFRESH 
}); 
currentWin4.setLeftNavButton(refreshBtn); 
currentWin4.add(refreshBtn); 





var l1 = Ti.UI.createLabel({ 
    left: 10, 
    top: 15, 
    width:'auto', 
    height:40, 
    color: '#1E90FF', 
    text: 'About us', 
    font: { 
     fontWeight: 'bold', 
     fontSize: 20 
    } 
}); 
scrollView4.add(l1); 





var l2 = Ti.UI.createLabel({ 
    left:10, 
    top: 50, 
    width:'auto', 
    height:40, 
    color: '#336699', 
    text: 'photo sharing app', 
    font: { 
     fontSize: 13 
    } 
}); 
scrollView4.add(l2); 





var l3 = Ti.UI.createLabel({ 
    left: 10, 
    top: 90, 
    width:'auto', 
    height:40, 
    color: '#336699', 
    text: '', 
    font: { 
     fontSize: 13 
    } 
}); 
scrollView4.add(l3); 









var l5 = Ti.UI.createLabel({ 
    left: 10, 
    top: 170, 
    width:'auto', 
    height:40, 
    color: '#336699', 
    text: 'locate us!', 
    font: { 
     fontSize: 13 
    } 
}); 
scrollView4.add(l5); 





var l6 = Ti.UI.createLabel({ 
    right: 10, 
    top: 250, 
    width:'auto', 
    height:40, 
    color: '#1E90FF', 
    text: 'Development & API', 
    font: { 
     fontWeight: 'bold', 
     fontSize: 20 
    } 
}); 
scrollView4.add(l6); 





var b1 = Ti.UI.createButton({ 
    right: 10, 
    top: 290, 
    width:'auto', 
    height:40, 
    color: '#336699', 
    title: 'Development & API', 
    font: { 
     fontSize: 13 
    } 
}); 
scrollView4.add(b1); 







var l9 = Ti.UI.createLabel({ 
    center: 0, 
    top: 460, 
    width: 'auto', 
    height: 40, 
    color: '#1E90FF', 
    text: 'complaints?' 
}); 
scrollView4.add(l9); 





var b2 = Ti.UI.createButton({ 
    center: 0, 
    top: 500, 
    width:'auto', 
    height: 40, 
    color: '#336699', 
    title: 'talk to us' 
}); 
scrollView4.add(b2); 





var emailDialog = Titanium.UI.createEmailDialog({toRecipients:['[email protected]']}); 
     emailDialog.Subject = (''); 
     emailDialog.messageBody = ''; 





b2.addEventListener('click',function(e) 
{ 
    emailDialog.open(); 
}); 





emailDialog.addEventListener('complete',function(e) 
{ 
    if (e.result == emailDialog.SENT) 
    { 
     alert("message sent"); 
    } 
    else 
    { 
     alert("message not sent"); 
    } 
+0

得到任何代碼?不清楚你在問什麼。 –

+0

感謝您的回覆,我已經用示例代碼編輯了我的問題(選項卡) –

+0

好的...我並不是指代碼轉儲,您是否可以將其修剪到您認爲的問題所在? –

回答

1

您必須實現一個事件處理程序

refreshBtn.addEventHandler('click', function(e) { 
    //Add code here that will fetch row data and redraw. 
} 

而不必更多信息這是很難回答更具體

+0

感謝您的回覆,我已經編輯我的問題與示例代碼(選項卡) –

0

我沒有看到你的代碼,任何代表的任何數據可以刷新...一般來說,你需要一個「點擊」按鈕的事件處理程序。 在click處理程序中,您可以使用TableView對象上的setData()方法爲TableView設置數據。

或者對於WebView,您可以重新加載它的URL。

如果你想重新繪製窗口/視圖,恐怕沒有專門的方法。如果applyProperties()導致重繪,您可以嘗試。但我不確定爲什麼一開始就想這樣做。

如果您告訴我們關於要刷新的數據的更多信息,這將有所幫助。什麼樣的數據,它來自哪裏等等。