English 中文(简体)
用户 t中具有约束力的数据的最佳实践是什么,以避免记忆失事
原标题:What are the best practises for data binding in appcelerator titanium and avoid memory crash

我一直在利用习俗活动处理与 t器具有约束力的数据,利用一个名为“RefreshComp”的活动(所有物体的特性)处理特定物品,并赋予新价值。 这种新价值可能来自一项推介通知,一种在电话中经过编辑的标语,即你想要向所有人传播......

Titanium.App.fireEvent(RefreshComp, {
    refreshid : objectId +  -  + attribute,
    value : newvalue
 });

以及

function registerEvent(objectId,attribute,eventHandler){
    Titanium.App.addEventListener(RefreshComp, function(e) {
        if((e.refreshid === (objectId +  -  + attribute))) {
            eventHandler(comp, e.value);
        }
    });
}

以及then your eventHandler function could be as simple as

function eventHandler(comp,newvalue){
    comp.value = newvalue;
}

或更复杂(如不断变化的背景......)

我的意思是,这造成参与者受全球环境的约束,从而不会释放目标。 我试图将习俗活动附在构成部分本身,但并不奏效。 因此,我正在收到正在坠毁的申请。

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x242424cf

because the binding refer to a component still in memory on the IOS side but then when TiViewProxy.m calls for the parent function in _hasListeners , it is not able to find the parent in memory that does not have any associated object 以及the parent has been removed form the memory

I have googled 以及look at the git rep of appcelerator but there are no example of this.

问题回答

there a millions of way to refresh special components. i usually tend to have a clean and simple structure where every js file constists of one single ui element. this provides a clean way of managing your ui. and if your component listens to an event like globalRefreshEvent it refreshs itself.

createMyComponent = function(_args){

   var myComp = Ti.UI.createWhatEver({
      property0 = _args.prop0 || "defaultValueForProp0"
      property1 = _args.prop1 || "defaultValueForProp1"
      value = _args.value || "defaultValueForValue"
  });

  myComp.refreshValue = function(_newValue){
       myComp.value = _newValue;
  };

  Ti.App.addEventListener( globalRefreshEvent ,function(e){
       myComp.refreshValue(e.value)
  });

  return myComp;
};

create:

var comp = createMyComponent();
view.add(comp);

我们希望它帮助了一点。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签