Appcelerator中页面刷新功能的问题 [英] Problems with refresh function for page, in Appcelerator

查看:26
本文介绍了Appcelerator中页面刷新功能的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Titanium SDK 版本:1.6.1iPhone SDK 版本:4.2

Titanium SDK version: 1.6.1 iPhone SDK version: 4.2

我正在使用 JavaScript.

I am using JavaScript.

我正在开发一个从 API 获取信息的应用.在这个应用程序中,在这个页面上,我有两种刷新"内容的方法.当窗口聚焦时以及当我点击刷新按钮时.

I am developing an app that is fetching information from an API. In this app, on this page, I got two ways of "refreshing" the content. When the window is focused and when I tap the refresh button.

问题是每次我刷新页面时,新内容下都会有内容的副本".这就像应用程序只是不断地将内容的新副本分层放置在每个新鲜内容的其他副本之上.

The problem is every time I do a fresh of the page there is a "copy" of the content under the new content. It is like the app just keeps layering on new copies of the content on top of the others on each fresh.

我的代码做错了什么?有没有办法在每次刷新之前清除"页面.我可以想象这个问题会占用大量内存.

What am I doing wrong in my code? Is there a way to "clear" the page before each refresh. I can imaging that this issue eats a lot of memory.

你可以在这里找到我的页面代码:http://pastie.org/1778830

You can find my code for the page here: http://pastie.org/1778830

推荐答案

这是一个常见的架构问题,你应该把创建表和加载表数据的功能分开.

this is a common architectural problem, you should separate out the function of creating the table and loading the table's data.

在创建窗口时创建一次表,并多次加载表中的数据.下面的伪代码应该给你基本的想法.

you create the table once when the window is created, and you load the data in the table multiple times. Pseudo code below should give you the basic idea.

var win = Ti.Ui.currentWindow;
(function(){
   var table;

   // create the table
   function initializeWindow() {
   }

   // load the data, and update table
   function loadWindowData() {
   }

   initializeWindow();
   loadWindowData();

   // called whenever you want to update window data.
   Ti.App.addEventListener('app:refreshTable',loadWindowData);
)();

这篇关于Appcelerator中页面刷新功能的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆