【问题标题】:create and set ios refresh buttons in titanium在钛中创建和设置 ios 刷新按钮
【发布时间】:2013-11-10 10:51:55
【问题描述】:

我知道如何在 Titan 中创建和设置 iOS 刷新按钮,但我不知道如何让它们真正刷新选项卡/窗口中的数据。我为我的 app.js 和其他四个选项卡创建了刷新按钮,但它不会刷新数据。

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:['zyaine@gmail.com']});
        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");
    }

【问题讨论】:

  • 有代码吗?没有它就不清楚你在问什么。
  • 感谢您的回复,我已经用示例代码(选项卡)编辑了我的问题
  • 好吧...我不是说代码转储,你能把它精简到你认为的问题吗?
  • 您的代码中没有任何内容可用于刷新 Button 的 listner 。刷新是什么意思?你愿意点击刷新按钮清除归档数据吗?另一件事,您在左侧导航和滚动视图中添加刷新按钮。清楚你想要什么得到正确的解决方案,谢谢
  • 请原谅我,我对钛的知识还不是很了解...我有刷新按钮,但我想,点击它会刷新页面中的数据。如果仍然不能很好地解释它,请给我一个我可以学习的示例代码。谢谢。

标签: button titanium refresh appcelerator simulator


【解决方案1】:

你必须实现一个事件处理程序

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

没有更多信息,很难更具体地回答

【讨论】:

  • 感谢您的回复,我已经用示例代码(选项卡)编辑了我的问题
【解决方案2】:

我在您的代码中看不到任何表示可以刷新的数据的任何内容...通常,您需要一个按钮的“单击”事件处理程序。 在点击处理程序中,您可以例如使用 TableView 对象上的 setData() 方法为 TableView 设置数据。

或者对于 WebView,您可以重新加载它的 URL。

如果您想重新绘制窗口/视图,恐怕没有专门的方法。如果 applyProperties() 导致重绘,您可以尝试。但我不确定为什么一开始就想这样做。

如果您能告诉我们更多有关您要刷新的数据的信息,将会很有帮助。什么样的数据,来自哪里等等。

【讨论】:

    猜你喜欢
    • 2018-01-30
    • 2013-05-11
    • 1970-01-01
    • 1970-01-01
    • 2015-09-08
    • 2012-06-21
    • 1970-01-01
    • 2019-08-30
    • 1970-01-01
    相关资源
    最近更新 更多