【问题标题】:Displaying new data under selected row in a table view在表格视图的选定行下显示新数据
【发布时间】:2012-03-09 21:21:59
【问题描述】:

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

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

当我们再次选择该行时,它必须再次显示 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;
     }

【问题讨论】:

    标签: iphone ios uitableview


    【解决方案1】:

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

    祝你好运!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-09
      相关资源
      最近更新 更多