iOS UITableView cellForRowAtIndexPath未调用

iOS UITableView cellForRowAtIndexPath未调用,ios,xcode,ios7,ios5,Ios,Xcode,Ios7,Ios5,是UITableView numberOfRowsInSection未呼叫。但是没有调用CellForRowatineXpath。我不明白为什么不调用CellForRowatineXpath。如果我重新运行节中的行数 return (allOfficedata.count >0)? allOfficedata.count + 1 : allOfficedata.count; Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPa

是UITableView numberOfRowsInSection未呼叫。但是没有调用CellForRowatineXpath。我不明白为什么不调用CellForRowatineXpath。如果我重新运行节中的行数

 return (allOfficedata.count >0)? allOfficedata.count + 1 : allOfficedata.count; 
 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];

 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
如果我给出返回数组计数,则不调用cellforrowatindexpath;或返回11;工作正常,我附上了我的代码,错误

 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
*****由于未捕获的异常“NSRangeException”而终止应用程序,原因:“*-[\uu NSArrayM objectAtIndex:]:索引10超出边界[0..9]”

-(NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView==self.LeftMenuTable)
        return leftOptions.count;
    return [allOfficedata count]+1;

}
**********************************************************************
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView==self.LeftMenuTable)
        return 60;

    Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
    NSString  *checkType =  fmodel.achievementType;
    if (isPad)
    {
        if (indexPath.row == 0)
        {
            return (isPad)?300.0:434.0;
        }
        else if (indexPath.row == allOfficedata.count+1)
          {return 30.0;}
        else{
        if (![checkType isEqualToString:@""] || [checkType isEqualToString:@"0"] || [checkType isEqualToString:@"1"])
            return ([fmodel.feedCommentCount integerValue] > 0)?366:318;
        else
            return  ([fmodel.feedCommentCount integerValue] > 0)?249:200;
        }
        return 0.0;
    }
    else
    {
        if (indexPath.row == 0)
        {
            return (isPad)?232.0:434.0;
        }
        else
        {
            if (![checkType isEqualToString:@""] || [checkType isEqualToString:@"0"] || [checkType isEqualToString:@"1"])
                return ([fmodel.feedCommentCount integerValue] )?259:222;
            else
                return  ([fmodel.feedCommentCount integerValue])?184:142;
        }
        return 0.0;
    }
}
***************************************************************
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier3 = @"loadMore";
    static NSString *CellIdentifier = @"TableViewCell";

    if (tableView==self.LeftMenuTable)
    {
        TableViewCell *cell = (TableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil)
        {
            NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:self options:nil];
            cell = [topLevelObjects objectAtIndex:0];

            UIView *sepView=[[UIView alloc ]initWithFrame:CGRectMake(0,59, 250, 1)];
            [cell.contentView addSubview:sepView];
            [sepView setBackgroundColor:[UIColor grayColor]];
        }

        cell.cellTextLabel.textColor=[UIColor whiteColor];
        [cell.cellTextLabel setText:[[leftOptions objectAtIndex:indexPath.row] valueForKey:@"name"]];
        [cell.CellImageView setImage:[UIImage imageNamed:[[leftOptions objectAtIndex:indexPath.row] valueForKey:@"image"]]];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        cell.backgroundColor=[UIColor clearColor];

        return cell;
    }
    else
    {
        NSUInteger row = [indexPath row];
        NSInteger countRoe = [allOfficedata count];
          if (row == countRoe )
          {


              UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier3];
              if (cell == nil) {
                  cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier3];
              }
              cell.textLabel.text = @"LoadMore";
              return cell;

          }else
         {
             if (indexPath.row == 0)
             {
                 //CellCallOutBox_Onboarding_iPad
                 //CellCalloutbox_Office_iPad
                 //CellCalloutbox_Office_iPhone

                 NSString *nibName;
                 if ([calloutOffice.is_empty_daily_mission isEqualToString:@"false"]) {
                     nibName = (isPad)?@"CellCalloutbox_Office_iPad":@"CellCalloutbox_Office_iPhone";

                 }
                 else if ([calloutOffice.is_empty_onboarding_mission isEqualToString:@"false"])
                 {
                     nibName = (isPad)?@"CellCallOutBox_Onboarding_iPad":@"CellCallOutBox_Onboarding_iPhone";
                 }
                 else if ([calloutOffice.is_empty_community_mission isEqualToString:@"false"])
                 {
                     nibName = (isPad)?@"CellCallOutBox_Onboarding_iPad":@"CellCallOutBox_Onboarding_iPhone";
                 }

                 CellCalloutbox_Office *cellcallout = (CellCalloutbox_Office *)[tableView dequeueReusableCellWithIdentifier:nibName];

                 if (cellcallout == nil)
                 {
                     NSArray *nib = [[NSBundle mainBundle] loadNibNamed:nibName owner:self options:nil];
                     cellcallout = [nib objectAtIndex:0];
                 }
                 cellcallout.aMissionDelegate = self;
                 [cellcallout.btnVideoOfTheDay addTarget:self action:@selector(videoOfTheDay) forControlEvents:UIControlEventTouchUpInside];
                 cellcallout.backgroundColor=[UIColor clearColor];
                 [cellcallout setArraywithCallOut:calloutOffice expanded:isCallOutOfficeExpanded];
                 [cellcallout.btnBackCallout addTarget:self action:@selector(calloutBack) forControlEvents:UIControlEventTouchUpInside];
                 [cellcallout.btnDailyMission addTarget:self action:@selector(openCalloutDilyMission) forControlEvents:UIControlEventTouchUpInside];

                 return cellcallout;
             }


             Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
             NSString  *checkType =  fmodel.achievementType;

             if (![checkType isEqualToString:@""] || [checkType isEqualToString:@"0"] || [checkType isEqualToString:@"1"])

             {
                 static NSString *simpleTableIdentifier = @"CellWithImageVideo";

                 CellWithImageVideo *cell = (CellWithImageVideo *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
                 NSString *nibNmaeForiPad = (([fmodel.feedCommentCount integerValue])?@"CellWithImage_Comment_iPad":@"Cell_WithImage_MyOffice_iPad");
                 NSString *nibNmaeForiPhone = (([fmodel.feedCommentCount integerValue])?@"CellWithImagewithComment_iPhone":@"CellWithImageVideo");
                 if (cell == nil)
                 {
                     NSArray *nib = [[NSBundle mainBundle] loadNibNamed:(isPad)?nibNmaeForiPad:nibNmaeForiPhone owner:self options:nil];
                     cell = [nib objectAtIndex:0];
                 }
                 cell.backgroundColor=[UIColor clearColor];
                 cell.contentView.backgroundColor=[UIColor clearColor];
                 [cell setFeeddata:fmodel indexPath:indexPath];


                 [cell.hifiveBtn         addTarget:self action:@selector(hifiveClickedMyOfiice:) forControlEvents:UIControlEventTouchUpInside];
                 [cell.playMintBtn       addTarget:self action:@selector(getFeedDetails:) forControlEvents:UIControlEventTouchUpInside];
                 [cell.planToDoBtn       addTarget:self action:@selector(planToDoClickedOffice:) forControlEvents:UIControlEventTouchUpInside];
                 [cell.userImageBtn      addTarget:self action:@selector(gotouserProfile:) forControlEvents:UIControlEventTouchUpInside];
                 [cell.inspireBtn        addTarget:self action:@selector(InspireClicked:) forControlEvents:UIControlEventTouchUpInside];
                 [cell.sendCommentBtn    addTarget:self action:@selector(serverCommentPost:) forControlEvents:UIControlEventTouchUpInside];
                 [cell.btnCompliment     addTarget:self action:@selector(getFeedCommentPopup:) forControlEvents:UIControlEventTouchUpInside];

                 cell.txtFldCommentField.delegate  = self;
                 return  cell;
             }
             else
             {
                 static NSString *simpleTableIdentifier = @"CellWithoutImage";
                 NSString *nibNmaeForiPad = (([fmodel.feedCommentCount integerValue])?@"Cell_withoutImage_withcomment_iPad":@"Cell_withoutImage_Ipad_Office");
                 NSString *nibNmaeForiPhone = (([fmodel.feedCommentCount integerValue])?@"CellWithoutImagewithComment_iPhone":@"CellWithoutImage");


                 CellWithoutImage *cell = (CellWithoutImage *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
                 if (cell == nil)
                 {
                     NSArray *nib = [[NSBundle mainBundle] loadNibNamed:(isPad)?nibNmaeForiPad:nibNmaeForiPhone owner:self options:nil];
                     cell = [nib objectAtIndex:0];
                 }
                 [cell setFeeddata:fmodel indexPath:indexPath];
                 cell.backgroundColor=[UIColor clearColor];
                 cell.contentView.backgroundColor=[UIColor clearColor];



                 [cell.hifiveBtn         addTarget:self action:@selector(hifiveClickedMyOfiice:)           forControlEvents:UIControlEventTouchUpInside];
                 [cell.planToDoBtn       addTarget:self action:@selector(planToDoClickedOffice:)           forControlEvents:UIControlEventTouchUpInside];
                 [cell.userImageBtn      addTarget:self action:@selector(gotouserProfile:)                 forControlEvents:UIControlEventTouchUpInside];
                 [cell.inspireBtn        addTarget:self action:@selector(InspireClicked:)                  forControlEvents:UIControlEventTouchUpInside];
                 [cell.btnCompliment     addTarget:self action:@selector(getFeedCommentPopup:)                   forControlEvents:UIControlEventTouchUpInside];
                 [cell.sendCommentBtn     addTarget:self action:@selector(serverCommentPost:)               forControlEvents:UIControlEventTouchUpInside];
                 [cell.btnTextMintTapped    addTarget:self action:@selector(getFeedDetails:)               forControlEvents:UIControlEventTouchUpInside];

                 cell.txtFldComment.delegate = self;
                 return cell;
             }
         }
    }
}
 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];

因此,您说allOfficedata+1表示部分中的行数,但高度表示行数:您有以下行:

 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
这会导致最后一个单元格崩溃,因此您需要检查它是否是最后一个单元格,以及它是否正在执行其他操作

 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
编辑:

 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
而且你似乎在CellForIndexath中也做了类似的事情

 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
如果(indexPath==0),您将执行某些操作,但在这之后,对于下一个单元格,您将获得:

 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
您应该从indexPath.row中得到-1,因为当前您对位于的单元格的get,比如indexPath.row==1,您在索引1处请求对象,我认为您应该请求0。当你到达最后一个单元格时,应用程序将在上面的一行崩溃

 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
编辑2:

 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
因此,问题是您向allOfficedata请求一个不存在的索引,当您对行说allOfficedata+1时,当它到达表中最后一个单元格的高度ForRowAtIndexPath时,它向allOfficedata请求不存在的索引的数据,因为它正在查找您在numberOfRowsInSection中给出的+1

 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
假设allOfficedata的计数是10(索引0-9),我们已经说过表中的行数是allOfficedata+1,所以它是11(索引0-10)

 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];

现在在HeightForRowatineXpath中,我们看到最后一个单元格(索引10),allOfficedata没有它,因为它的索引是0-9。如果向allOfficedata请求索引10,它将崩溃

NSArray
出界了

 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
  • 数组0到9中的10个值[1到10]
  • 表中的索引也是 相同的0到9[不是1到10]

因此,
indexpath.row
将为您提供正确的值,用于从位于正确位置的数组中确定值

除了行计数错误之外,cellForRowAtIndexPath从未被调用的最可能原因是表视图认为没有要显示的行

 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
cellForRowAtIndexPath仅在需要单元格时调用。您的代码中似乎有高度非常大的单元格。无法看到节标题视图或高度的任何代码

 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
因此,考虑到很大的高度,特别是对于第0行(根据您的代码为300或400),除非您向上滚动,否则不会有太多对该函数的调用。滚动时,您应该会看到更多对单元格的调用

 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
还要检查高度是否返回0,因为这也会阻止它尝试显示单元格,我认为它不会被看到

 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];

它将要求每行的高度来估计所需的滚动条大小。

检查
numberofrowsinssection
返回的值。我正在返回return[allOfficedata count]+1;同样的问题我不知道
[allOfficedata count]+1的值是多少,我怎么知道?你能解释一下你想做什么吗?allOfficedata是一个数组,检查:[Array count]+1;或数组。计数+1;它不是调用CellForRowatineXpath。我已经尝试了更多的例子。它不会到达cellAtIndexPath,因为在那之前它会在Rowatindexpath的高度坠毁。我检查了这个东西。当我在那里返回值时,它的获取错误。如果我手动返回11表示其工作,如果我这样返回表示返回NSArray.count+1;意思是显示错误。安德问题解决-切扬帮我
 Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];