如何管理不同部分中的不同行数?行数和节数不固定取决于其他类中的另一个表视图。假设如果 xxx 节标题则它包含 5 行,另一个节标题包含 4 行。部分标题是其他类的表视图中的帐户标题
			
			1858 次
		
5 回答
            2        
        
		
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
     return 3; or [yourarray count] // 3 sections 0,1,2
}
对于不同部分的不同行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the sections.
    if(  section == 0) // first section with 5 rows
        return [[yourarray objectAtIndex:section] count];
     if(  section == 1) // 2nd section with 4 rows
        return  [[yourarray objectAtIndex:section]  count];
     if(  section == 2) // 3rd section with 57rows
         return  [[yourarray objectAtIndex:section] count];
}
    于 2012-04-20T05:00:02.730   回答
    
    
            1        
        
		
在表视图委托方法中;它有:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
     return data.count;
}
和
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
     return [data objectAtIndex:section].count;
}
您可以在这两种方法中设置节数和行数。
当然,您还必须将数据配置为二维数组。
于 2012-04-20T04:57:11.510   回答
    
    
            1        
        
		
希望能帮助到你:
 - (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];
}
    于 2012-04-20T05:06:56.460   回答
    
    
            0        
        
		
它真的很简单,使用下面的 tableView 代表 -
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
  // return your another table view's array count here, on which no of sections depends.
}
// Customize the number of rows in the table view.
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
   // use like this
  int noOfRows = 0; 
  if(section == 0)
  {
     noOfRows = x;
  }
  else if(section ==1)
  {
     noOfRows = y;
  }
  .
  .
  .
  else
 {  
    noOfRows = z;
 }
 return noOfRows;
}
x, y, z 在这里是 NSInteger
于 2012-04-20T04:52:55.630   回答
    
    
            0        
        
		
试试这个
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0){
        return 5;
    }
    if (section == 1){
        return 10;
    }
    //etc.
}
    于 2012-04-20T05:00:12.513   回答