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

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

问题描述

Titanium SDK版本:1.6.1 iPhone 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天全站免登陆