我在Titanium的屏幕上工作,它有几个输入文本字段和标签以及一个继续按钮。在继续按钮单击我删除我的变量'容器'并添加一个不同的容器与不同的文本字段等。这是非常基本的,但在我的继续按钮单击事件,我得到随机崩溃,可能是60-70%的它崩溃的时间。它报告的错误就是那条消息,“不幸的是<>已关闭'。任何想法可能是什么?继续下面的按钮事件监听器,当我在调试模式下运行时,我正在进行崩溃3。日志似乎表明我有权拒绝,但实际上我所做的只是用不同的视图替换视图。我很难过:
var self = Ti.UI.createWindow({
title:title,
backgroundColor:'#33336F'
});
var Container=Ti.UI.createView({
top:'40dp',
width:'100%'
});
var Container2=Ti.UI.createView({
top:'40dp',
width:'100%'
});
Continue_btn.addEventListener('click', function (e){
console.log('--------------------- '+ self);
console.log('--------------------- Title_textfield val is '+Title_textField.value);
console.log('--------------------- Trade_picker val is '+Trade_picker.getSelectedRow(0).title);
console.log('--------------------- Urgent_image val is '+Urgent_image.image);
Post_array.push({
Title:Title_textField.value,
Trade:Trade_picker.getSelectedRow(0).title,
Urgency:(Urgent_image.image == "urgentChecked1.png")?"0":"1",
ClientID:8
});
console.log("--------------- Post_array is " + Post_array[0].Title+' - '+ Post_array[0].Trade + ' - ' + Post_array[0].Urgent);
console.log('-------- crash 1');
Continue_btn.setBackgroundImage('/images/continue2.png');
console.log('-------- crash 2');
console.log("Is self val undefined ------ "+ self.value + " or is Container val undefined ----- "+ Container.value + " or is container 2 val unndefined ------ "+ Container2.value);
console.log("Is self typeof undefined ------ "+ typeof self + " or is Container typeof undefined ----- "+ typeof Container + " or is container 2 typeof unndefined ------ "+ typeof Container2);
self.remove(Container);
console.log('-------- crash 3');
self.add(Container2);
console.log('-------- crash 4');
Navbar.add(BackArrow_btn);
console.log('-------- crash 5');
});
日志
[INFO][TiAPI (30736)] -------- crash 1
[INFO][TiAPI (30736)] -------- crash 2
[INFO][TiAPI (30736)] Is self val undefined ------ undefined or is Container val undefined ----- undefined or is container 2 val unndefined ------ undefined
[INFO][TiAPI (30736)] Is self undefined ------ object or is Container undefined ----- object or is container 2 unndefined ------ object
[DEBUG][SensorManager(30736)] unregisterListener:: Trklfufi 9 budiwrd5mrfo5WirfulblrwuFmfulTrklfufi$KfukwiFmfulTrklfufiRvht@,)-.d--(
[DEBUG][Sensors (30736)] Remain listener = Sending .. normal delay 200ms
[INFO][Sensors (30736)] sendDelay --- 200000000
[INFO][SensorService( 2030)] info.selectDelay() ns=20000000
[DEBUG][SensorService( 2030)] SensorDevice::setDelay, Return(true 1, false 0) = 1
[DEBUG][SensorManager(30736)] JNI - sendDelay
[INFO][SensorManager(30736)] Set normal delay = true
[DEBUG][SensorService( 2030)] SensorDevice::activating sensor handle=0 ns=20000000
[INFO][TiAPI (30736)] -------- crash 3
F/libc (30736): Fatal signal 11 (SIGSEGV) at 0x0000000c (code=1), thread 30755 (KrollRuntimeThr)
[WARN][IInputConnectionWrapper(30736)] getSelectedText on inactive InputConnection
[WARN][IInputConnectionWrapper(30736)] setComposingText on inactive InputConnection
[WARN][IInputConnectionWrapper(30736)] getExtractedText on inactive InputConnection
编辑更新了事件监听器和日志信息。我没有太多其他代码可以包含,只是标签,文本字段和选择器的声明被添加到容器视图和container2视图
答案 0 :(得分:0)
//in Alloy
$.viewMain.remove( ... );
$.viewMain.add( ... );
//or JS
var viewMain = Ti.UI.createView(...);
viewMain.remove( ... );