Mik*_*cic 13 javascript iphone titanium
我正在使用Titanium开发一个iPhone应用程序,需要在特定的TableViewSection上添加一行.我无法在页面加载时执行此操作,因为它是在应用程序的整个生命周期中由用户动态完成的.文档说TableViewSection有一个add
方法,它接受两个参数,但我不能使它工作.这是我现有的代码:
for(var i = 0; i <= product_count; i++){
productsTableViewSection.add(
Ti.UI.createTableViewRow({
title:'Testing...'
})
);
}
Run Code Online (Sandbox Code Playgroud)
这只是传递一个参数,这导致Titanium死于未捕获的异常:
2010-04-26 16:57:18.056 MyApplication[72765:207] *** Terminating app due to uncaught
exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in
section 2. The number of rows contained in an existing section after the update (2) must be
equal to the number of rows contained in that section before the update (1), plus or minus the
number of rows inserted or deleted from that section (0 inserted, 0 deleted).'
2010-04-26 16:57:18.056 MyApplication[72765:207] Stack: (
Run Code Online (Sandbox Code Playgroud)
异常看起来确实添加了行,但由于某种原因不允许这样做.由于文档说明TableViewSection
了"视图"和"行",我尝试了以下内容:
for(var i = 0; i <= product_count; i++){
productsTableViewSection.add(
Ti.UI.createView({}),
Ti.UI.createTableViewRow({
title:'Testing...'
})
);
}
Run Code Online (Sandbox Code Playgroud)
上面的代码没有抛出异常,但它给出了一个[WARN]
:
[WARN] Invalid type passed to function. expected: TiUIViewProxy,
was: TiUITableViewRowProxy in -[TiUITableViewSectionProxy add:] (TiUITableViewSectionProxy.m:62)
Run Code Online (Sandbox Code Playgroud)
TableViewSections似乎不支持任何类似的方法appendRow
,或者insertRow
,所以我不知道在哪里可以使用它.我查看了KitchenSink应用程序,但没有找到向TableViewSection添加行的示例.任何帮助表示赞赏.
归档时间: |
|
查看次数: |
6969 次 |
最近记录: |