简体   繁体   English

从UITableView删除节

[英]Deleting sections from a UITableView

I'm writing an iOS app and I have a UITableView that starts out with 2 sections. 我正在编写一个iOS应用程序,并且有一个UITableView,它以2个部分开头。 What I want is that if someone deletes all of the rows from the first section then the entire section will disappear. 我想要的是,如果有人删除第一节中的所有行,那么整个节将消失。 My question is, when I delete section 0, does the remaining section now become section 0? 我的问题是,当我删除第0部分时,其余部分现在是否变为第0部分? Or is it still considered section 1? 还是仍视为第1节?

When I delete section 0, does the remaining section now become section 0? 当我删除第0部分时,其余部分现在是否变为第0部分?

Yes, of course. 当然是。 You need to update your data model properly before committing the deletion, or UITableView will most likely throw some heavy NSExceptions against you (personal experience). 在提交删除操作之前,您需要正确地更新数据模型,否则UITableView很可能会给您带来一些沉重的NSExceptions(个人经验)。

Yes, It is possible. 对的,这是可能的。 You just need to update the DataSource. 您只需要更新数据源。 After updating you just need to relaod the tableView. 更新后,您只需要重新装饰tableView。 It will get reflected. 它将得到反映。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM