0

ウィンドウがあるアプリがあります。そのウィンドウにはビューがあり、そのビューにはボタンがあります。ウィンドウを閉じて、ウィンドウが使用していたメモリを解放したい。

したがって、ウィンドウを反復処理してすべてのコントロールを取得するメソッドを作成して、使用後にビュー内のボタンなどの要素を null にすることができますか。

4

1 に答える 1

1

私はあなたがメモリを解放しようとしていて、メモリリークを防ぎたいと思っていると仮定しています.この方法でそれを行うことができます.

//create a window
var win = Titanium.UI.createWindow({
});
win.open();

//create a view
var view = Titanium.UI.createView({
});
win.add(view)//add view to window

//create button
var button = Titanium.UI.createButton({
  });
view.add(button);//add button to view
//similarly add what ever you want according to your requirement

//this will free memory
win.remove(view);  // view & button still exist
view = null; // deletes the view and its proxy, but not the button!
button = null;//deletes the button and delete all the elements what ever you have added

//if you have inserted views/tableviewrows/buttons and other elements into an array      then nullifying it after their use like this
var SampleArray = [];
//added views,rows etc...to this SampleArray 
SampleArray = null;

詳細については、メモリの管理とリークの検出に関する次のリンクを参照して ください。

于 2012-09-13T07:53:31.647 に答える