在表视图中的选定行下显示新数据

时间:2012-03-09 09:33:57

标签: iphone ios uitableview

我在屏幕上有一个表格视图,在打开视图时有五行。

当我们选择行时,新行将添加到所选行的下方(新行=来自其他视图的数组计数)。

当我们再次选择行时,它必须再次显示5行。就像在我的表视图中那样,当我们选择行时,将根据数组计数添加一些行。我再次点击它所拥有的同一行再次显示5行。我怎么能这样做?

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{
     return currentrows;
}

if(selectedIndex == 0)
{   
     for (int j=1;j<=[passionarray count];j++) 
     {
          currentrows = currentrows + 1;
          NSLog(@"numberofrowsatindex %d",currentrows);
          NSIndexPath *indexPath1 = [NSIndexPath indexPathForRow:j inSection:0];

          [tableView insertRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath1, nil] withRowAnimation:UITableViewRowAnimationFade];
          selected=YES;
     }

1 个答案:

答案 0 :(得分:0)

您是否正在重新加载表并强制它再次通过其数据源来刷新实际视图?它可能已经存在于我们无法看到的代码中的其他位置,但在扩充数据源以反映新行数后,请调用[tableView reloadData];

祝你好运!

相关问题