我有一个表格视图,我在其中动态返回每个部分的节数和行数。我可以这样实现
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if( section == 0)
return [array count];
if( section == 1)
return [array2 count];
if( section == 2)
return [array3 count];
}
如果我知道我有 3 个部分,我可以按照上述方式进行操作。但是如何动态定义不同部分的行数。例如:- 你有 if(section == 0)。我不想在这里硬编码 0,1,2 的值。我不确定部分的总数。我们要如何动态返回不同部分的行数?我有一个数组来显示没有的部分和不同的数组来显示每个部分的行数。如何在方法“numberOfRowsInSection”中动态提及?