Objective c cellForRowAtIndexPath忽略节

Objective c cellForRowAtIndexPath忽略节,objective-c,uitableview,Objective C,Uitableview,在我的UITableViewController中,我定义了3个部分。但是,如果我想访问cellForRowAtIndexPath方法中比第一个方法中更多的部分,则会忽略这一点。例如,如果我想在第二节中添加一行。有人能解决这个问题吗 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 3; } - (UITableViewCell *)tableView:(UITableView *)tab

在我的UITableViewController中,我定义了3个部分。但是,如果我想访问cellForRowAtIndexPath方法中比第一个方法中更多的部分,则会忽略这一点。例如,如果我想在第二节中添加一行。有人能解决这个问题吗

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
   return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

if (indexPath.section == 0) {
    if (indexPath.row == 0) {
        ..
        return cell;
    }
    if (indexPath.row == 1) {
        ..
        return cell;
    }
    if (indexPath.row == 2) {
        ..
        return cell;
    }
}
if (indexPath.section == 1) {
            UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:aufgabe];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:aufgabe];
    }
    [cell.textLabel setText:@"Test"];
    }
}
else if (indexPath.section == 2) {
    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:geraet];
    return cell;
}
   return nil;
}

好笑!我自己修的。我必须用分段法填写行数

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
   if (section == 0) {
       return 3;
   }
   if (section == 1) {
       return 5;
   }
   else {
       return 0;
   }
}