UITableView 动态增加删除行
2013-10-17 09:30
267 查看
在UITableView中插入或者删除指定的行(或者节)使用的是如下几个API:
insertRowsAtIndexPath: withRowAnimation: 在指定位置插入行
deleteRowsAtIndexPath: withRowAnimation: 删除指定行
insertSections: withRowAnimation: 在指定位置插入节
deleteSections: withRowAnimation: 删除指定节
调用以上API之前,必须先调用beginUpdates,插入/删除数据完成后再调用endUpdates。
API用法示例:
[tableView beginUpdates];
NSArray *arrInsertRows = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]];
[tableView insertRowsAtIndexPaths:arrInsertRows withRowAnimation:UITableViewRowAnimationBottom];
[tableView endUpdates];
需要注意的是,在增加删除行操作时,必须更改tableView中Cell的总数,使其等于增加删除行操作执行完后应有的总数,例如:表格中原有2个section,各10个row,则若对第一个section增加/删除5行,则对应的numberOfRowsInSection方法中须返回的值分别为 if (0 == section) return 15; 以及 if (0 == section) return 5;
转自 http://blog.csdn.net/lytte_lj/article/details/7696786
insertRowsAtIndexPath: withRowAnimation: 在指定位置插入行
deleteRowsAtIndexPath: withRowAnimation: 删除指定行
insertSections: withRowAnimation: 在指定位置插入节
deleteSections: withRowAnimation: 删除指定节
调用以上API之前,必须先调用beginUpdates,插入/删除数据完成后再调用endUpdates。
API用法示例:
[tableView beginUpdates];
NSArray *arrInsertRows = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]];
[tableView insertRowsAtIndexPaths:arrInsertRows withRowAnimation:UITableViewRowAnimationBottom];
[tableView endUpdates];
需要注意的是,在增加删除行操作时,必须更改tableView中Cell的总数,使其等于增加删除行操作执行完后应有的总数,例如:表格中原有2个section,各10个row,则若对第一个section增加/删除5行,则对应的numberOfRowsInSection方法中须返回的值分别为 if (0 == section) return 15; 以及 if (0 == section) return 5;
转自 http://blog.csdn.net/lytte_lj/article/details/7696786
相关文章推荐
- UITableView 动态增加删除行
- UITableView 动态增加删除行
- iOS中给UITableView的侧滑删除增加多个按钮的实现方法
- UITableView的cell表格刷新(增加,删除,修改)
- 在UITableView中动态的插入或删除行(或者节)
- 在UITableView中动态的插入或删除行
- iOS UITableView实现滑动删除、增加、多选
- 在UITableView中动态的插入或删除行(或者节)
- 给UITableView的侧滑删除增加多个按钮
- 为嵌套在左右滑动的UIScrollview上的UITableView增加滑动删除
- fragment+viewpager+pageradapter以及动态增加删除fragment
- 为嵌套在左右滑动的UIScrollview上的UITableView增加滑动删除
- UI一揽子计划 10 (UITableView 中cell 的编辑, 增加, 删除、UITableViewController 、)
- iOS开发学习之利用系统远程UITableView 自定义滑动删除按钮、增加自定义滑动按钮方法
- 【精】表格(UITableView)总结(4):编辑(增加、删除、移动)
- ViewPager设置完FragmentPagerAdapter后动态的进行增加删除Fragment
- 在UITableView中动态的插入或删除行(或者节)
- UITableView,根据indexPath设置cell的编辑样式,删除cell ,增加cell &搜索条
- ViewPager+Fragment动态增加页面,删除页面
- 给UITableView的侧滑删除增加多个按钮