问题描述
我使用Appcelerator的钛移动API 1.7.2。
创建一个磁盘阵列时,我发现了一些奇怪的结果。它是我的语法?
container.textBoxArray =新的Array();
container.textBoxArray [0] = createPasswordTextField(选择,0%);
container.textBoxArray [1] = createPasswordTextField(选项,'25%');
Ti.API.log(container.textBoxArray == NULL);
Ti.API.log('长度:'+ container.textBoxArray.length);
的输出的结果是0(假)和len个:0'分别。任何人都知道为什么吗?
亚当
编辑:
createPasswordTextField基本上
函数createPasswordTextField(选项,左){
返回Ti.UI.createTextField(选项...)
}
我遇到这一点。当添加一个数组到TiProxy对象(景,窗,按钮等),预计这是行不通的。你需要操纵阵列关闭代理,然后再重新设置。我不知道这是一个错误,或只是一个上TiProxy对象的属性的限制。下面是表现在钛在iOS相同的实例移动SDK 1.7.5:
VAR代理= Ti.UI.createView(); //这可以是任何TiProxy对象proxy.someArray = [];
proxy.someArray.push('1');
proxy.someArray.push('2');
Ti.API.info(阵列直接TiProxy对象上修改);
Ti.API.info(proxy.someArray);myarray的无功= [];
myArray.push('1');
myArray.push('2');
proxy.someArray = myArray的;
Ti.API.info(数组修改TiProxy对象外);
Ti.API.info(proxy.someArray);proxy.someArray.push('3');
Ti.API.info(这将是不变);
Ti.API.info(proxy.someArray);VAR changeArray = proxy.someArray;
changeArray.push('3');
proxy.someArray = changeArray;
Ti.API.info(这是你必须怎么做。);
Ti.API.info(proxy.someArray);
返回:
[信息]数组直接修改TiProxy对象
[INFO] []
[信息]数组修改TiProxy对象外
[INFO] [1,2]
[INFO]这将是不变
[INFO] [1,2]
[INFO]这是你必须怎么做。
[INFO] [1,2,3]
找出Android上的水煤浆是很多困难bacause Ti.API.info(proxy.someArray);
只返回一个对象引用
I'm using Titanium Appcelerator mobile API 1.7.2.
When creating an array, I'm getting some odd results. Is it my syntax?
container.textBoxArray = new Array();
container.textBoxArray[0] = createPasswordTextField(options, '0%');
container.textBoxArray[1] = createPasswordTextField(options, '25%');
Ti.API.log(container.textBoxArray == null);
Ti.API.log('len: ' + container.textBoxArray.length);
The results of the output are 0 (for false) and 'len: 0' respectively. Anyone know why?
Adam
Edit:createPasswordTextField is essentially
function createPasswordTextField(options, left){
return Ti.UI.createTextField( options... )
}
I've come across this as well. When adding an array to a TiProxy object (View, Window, button etc.) it doesn't work as expected. You need to manipulate the array 'off' the proxy, then re-set it. I don't know if this is a bug or just a limitation of properties on TiProxy objects. Here is an example that behaves the same on iOS under Titanium Mobile SDK 1.7.5:
var proxy = Ti.UI.createView(); //this can be any TiProxy object
proxy.someArray = [];
proxy.someArray.push( '1' );
proxy.someArray.push( '2' );
Ti.API.info("Array modified directly on TiProxy object" );
Ti.API.info(proxy.someArray );
var myArray = [];
myArray.push( '1' );
myArray.push( '2' );
proxy.someArray = myArray;
Ti.API.info("Array modified outside TiProxy object" );
Ti.API.info( proxy.someArray );
proxy.someArray.push( '3' );
Ti.API.info("This will be unchanged" );
Ti.API.info(proxy.someArray );
var changeArray = proxy.someArray;
changeArray.push('3');
proxy.someArray = changeArray;
Ti.API.info("This is how you must do it." );
Ti.API.info(proxy.someArray );
returns:
[INFO] Array modified directly on TiProxy object
[INFO] []
[INFO] Array modified outside TiProxy object
[INFO] [ 1, 2 ]
[INFO] This will be unchanged
[INFO] [ 1, 2 ]
[INFO] This is how you must do it.
[INFO] [ 1, 2, 3 ]
Finding out the behavour on Android is a lot harder bacause Ti.API.info(proxy.someArray );
just returns an object reference.
这篇关于添加使用Appcelerator的钛移动1.7.2元素后空数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!