tableView的使用(二)当前tableView视图中添加一行cell
2014-08-18 15:12
471 查看
当你点击一个按钮触发addCell事件
-(void)addCell:(id)sender
{
[self.thirdTableView beginUpdates]; //告诉tableView将要开始更新
[delegate.mArray addObject:@"New Cell"]; //更新数据源
NSIndexPath *indexPathOfNewItem = [NSIndexPath indexPathForItem:delegate.mArray.count-1 inSection:0];
[self.thirdTableView insertRowsAtIndexPaths:@[indexPathOfNewItem] withRowAnimation:UITableViewRowAnimationAutomatic];
[self.thirdTableView endUpdates];
[self.thirdTableView scrollToRowAtIndexPath:indexPathOfNewItem atScrollPosition:UITableViewScrollPositionBottom animated:YES];
}
-(void)addCell:(id)sender
{
[self.thirdTableView beginUpdates]; //告诉tableView将要开始更新
[delegate.mArray addObject:@"New Cell"]; //更新数据源
NSIndexPath *indexPathOfNewItem = [NSIndexPath indexPathForItem:delegate.mArray.count-1 inSection:0];
[self.thirdTableView insertRowsAtIndexPaths:@[indexPathOfNewItem] withRowAnimation:UITableViewRowAnimationAutomatic];
[self.thirdTableView endUpdates];
[self.thirdTableView scrollToRowAtIndexPath:indexPathOfNewItem atScrollPosition:UITableViewScrollPositionBottom animated:YES];
}
相关文章推荐
- ViewPager+Fragment添加一行若干小红球滚动指示器指示当前ViewPager翻阅位置(可供第三方使用的类)
- ViewPager+Fragment添加一行若干小红球滚动指示器指示当前ViewPager翻阅位置(可供第三方使用的类)
- tableView一行显示多个视图
- ios tableView那些事(四)tableView添加标题,头尾和改变cell的宽度
- IOS编程教程: storyboard如何往表视图(Table View)添加搜索栏(Search Bar)
- IOS编程教程(十三):如何往表视图(Table View)添加搜索栏(Search Bar)
- UITableView (4): 在TableView中移动cell和Section 从TableView中删除cell和section 添加系统默认刷新控件
- TableView动态的删除,添加cell
- 使用sqlite3 有关tableview删除cell的问题
- 使用自定义的tableViewCell- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS
- 使用storyboard显示UITableView时,如果不修改系统默认生成的tableView:cellForRowAtIndexPath:方法中的代码,则必须为UITableViewCell注册(填写)重用标识符:identifier.必须要代码方法中的标识符一致.
- 使用HVTableView动态展开tableView中的cell
- tableView的中cell添加图像
- 如何使用js像html的table标签中添加一行
- 表视图单元函数 tableView:cellForRowAtIndex:
- UITableView cell自定义视图中插入Table实现复杂界面
- iOS界面不能点击(tableView 的cell 不能使用点击事件,tableView也不能上下滚动)
- iOS界面不能点击(tableView 的cell 不能使用点击事件,tableView也不能上下滚动)
- ios tableView那些事(四)tableView添加标题,头尾和改变cell的宽度
- 改变tableView中的cell选中的颜色和背景颜色 从父视图上删除所有的子视图