Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone Tableview中没有行的节数_Iphone_Objective C_Ios_Uitableview - Fatal编程技术网

Iphone Tableview中没有行的节数

Iphone Tableview中没有行的节数,iphone,objective-c,ios,uitableview,Iphone,Objective C,Ios,Uitableview,如何管理不同编号部分中不同编号的行?行数和节数不固定取决于其他类中的另一个表视图。假设xxx节头包含5行,另一节头包含4行。节头是来自其他类的表视图中的帐户标题它非常简单,在表视图下使用- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // return your another table view's array count here, on which no of sections depends.

如何管理不同编号部分中不同编号的行?行数和节数不固定取决于其他类中的另一个表视图。假设xxx节头包含5行,另一节头包含4行。节头是来自其他类的表视图中的帐户标题

它非常简单,在表视图下使用-

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

非常简单,使用下面的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;它有:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
     return data.count;
}

您可以在这两种方法中设置节数和行数


当然,您还必须将数据配置为二维数组

表视图中的委托方法;它有:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
     return data.count;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
     return 3; or [yourarray count] // 3 sections 0,1,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];



}
对于不同截面中的不同行数

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



}
试试这个

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0){
        return 5;
    }
    if (section == 1){
        return 10;
    }
    //etc.
}
试试这个

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0){
        return 5;
    }
    if (section == 1){
        return 10;
    }
    //etc.
}
希望有帮助:

 - (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];
}
希望有帮助:

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

嘿,我知道那个方法是的。但我不能完全做到。我想我弄糊涂了我必须检查的条件是什么?是的。它帮助我:Naina。thnks againhey我知道那个方法是的。但我不能完全做到。我想我弄糊涂了我必须检查的条件是什么。是的。它帮助我:Naina。thnks againJason:-我还必须检查部分。因为它没有修复你的错误是的,但我必须像If(section==“xxx”)一样返回数据。count..If(section==“yy”)返回不同的数组计数..@success如果您查看tableView-numberofrowsinssection(第二组代码),Jason的答案就是您需要的答案它根据节索引检查数组中的每个记录,并返回记录数原因:-我还必须检查节..因为它不正确,但我必须做的是,如果(节==“xxx”)返回数据。计数..如果(节==“yy”)返回不同的数组计数..@success Jason的答案是您需要的答案,如果您查看tableView-numberOfRowsInSection(第二组代码)它根据节索引检查数组中的每个记录,并返回记录数节不固定其依赖于其他类中的fecth,因此我无法像这样进行检查节位于不同数组中的fecth,并且所有行也不同arraysection不固定其依赖于其他类中的fecth,因此我无法像这样进行检查这些节位于不同数组的fecth中,所有的行也具有不同的数组,但是这里如何动态地给出这些值…例如:-u have if(节==0)。我不想在这里硬编码0,1,2的值。我不确定总共有多少节。我们如何做我们想为不同的部分动态返回行数?但是这里如何在这里动态给出值…例如:-u have if(section==0)。我不想在这里硬编码0,1,2的值。我不确定总共有多少节。如果我们想动态返回不同部分的行数,我们该怎么做?