自从我将应用程序更新到最新的 sdk 版本后,我的 TableViewSection
似乎不再更新新行。
这是我的看法:
<Alloy>
<Tab id="customers" title="Customers" icon="glyphicons/glyphicons/png/glyphicons_003_user.png">
<Window id="customers_window" title="Customers">
<RightNavButton>
<Button id="add">Add</Button>
</RightNavButton>
<TableView id="table" filterAttribute="title">
<SearchBar platform="android,ios"/>
<TableViewSection id="customers_list"></TableViewSection>
</TableView>
</Window>
</Tab>
</Alloy>
这是我的 Controller :
...
function customersCallback (customers, callback) {
// throw those into globals so we can use them again
Alloy.Globals.customers = customers;
// empty list first
$.customers_list.rows = [];
customers.forEach(function(customer) {
Ti.API.info(customer);
var payload = {
customer : customer
};
var row=Alloy.createController('customer_row',payload).getView();
$.customers_list.add(row);
});
// tell async we're finished
callback(null);
};
...
我在某处读到,现在可以在渲染 TableViewSection
时使用 appendRow
。但是,当我尝试使用它时,我得到:
'undefined' is not a function (evaluating '$.customers_list.appendRow(row)') at customers.js (line 11)
无论如何我可以强制和更新吗?或者访问 appendRow
?
钛金 SDK 3.2.0 GA
部署到 iOS 模拟器 v7
最佳答案
查看文档,您的 customer_list 是一个 TableViewSection,而 appendRow 似乎不是一个函数。对于 TableViewSection,您使用函数“添加”具有以下注释:
Adds a table view row to this section.
Should be called before adding the section to a table. Calling add on a section that's already been added to a table does not update the table.
To add a row to a section after it's been added to a table, call one of the TableView methods, insertRowBefore, insertRowAfter, or appendRow.
On Android, it is possible to update a section by adding or removing rows and then resetting the table view's data property. However, this approach is not portable and is not recommended.
http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.UI.TableViewSection-method-add
如果不使用他们在文档中说要避免的方法,我找不到任何具体的例子, How to append a row to a TableViewSection in Titanium?
关于ios - Titanium 不使用新行更新 TableViewSection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21380517/