![](/img/trans.png)
[英]how can I refresh a single button in UITableViewCell instead of refreshing whole table or whole cell?
[英]How can I deinit my UITableViewCell instances when I refresh the table?
當我刷新我的表格時,我希望所有以前的單元格都取消初始化(但它沒有發生)。 我很確定我沒有任何參考資料。
這是我的刷新方法:
apiClient.listUsersNow(start, num: num, filter: filter) { [weak self] (response) -> Void in
if self != nil && response != nil && response["status"] == "success"{
self!.items = [] //data source
self!.tableView.reloadData()
for(_, stuff): (String, JSON) in response["data"]["results"]{
if let user_id = stuff["id"].int {
self!.items.append(user_id)
}
}
self!.tableView.reloadData()
}
callback()
}
我的印象是,當我叫下reloadData()
舊的細胞應該由自己,我做手工我不需要DEINIT。
顯然我錯了……我必須循環遍歷每個單元格並在重新加載數據之前調用cleanupCell()
嗎?
您不必做任何事情,單元格會根據 tableview 單元格的需要進行分配/解除分配。 tableview 維護一組單元格並根據需要重用它們。 所有你需要做的是利用dequeuereusablecellwithidentifier
在tableview中的數據源方法cellforrowatindexpath
。 或者,您可以手動創建它們,但如果您沒有對它們的strong
引用,它們會由 ARC 自動解除分配。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.