简体   繁体   English

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

[英]Displaying new data under selected row in a table view

I have a table view on the screen which has five rows when the view is opened. 我在屏幕上有一个表格视图,该视图在打开时有五行。

When we select the row, new rows will added below the selected row (new rows = array count from other view). 当我们选择该行时,新行将添加到所选行的下方(新行=其他视图中的数组计数)。

When we select the row again, it has to display 5 rows again. 当我们再次选择该行时,它必须再次显示5行。 Like that in my table view when we select the row some rows will be added based on array count. 就像在我的表格视图中那样,当我们选择行时,将基于数组计数添加一些行。 Again I click the same row it has to display 5 rows again. 再次单击同一行,它必须再次显示5行。 How can I do that? 我怎样才能做到这一点?

- (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;
     }

Are you reloading the table and forcing it to go through its data source again to refresh the actual view? 您是否正在重新加载表并强制其再次通过其数据源以刷新实际视图? It may already be elsewhere in your code that we cannot see, but after augmenting your data source to reflect the new row count, call [tableView reloadData]; 我们可能看不到您代码中的其他地方,但是在扩充数据源以反映新的行数之后,请调用[tableView reloadData];

Good Luck! 祝好运!

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

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