numberOfSections被调用? iOS版

跳过所有这些信息并跳到底部的更新…

我之前已经处理了无法识别的select器,但我无法弄清楚这次发生了什么。 调用堆栈是不透明的,我不能找出问题来自哪里。 我曾尝试使用符号和exception断点。 这个代码之前完美的工作..我回来这个程序更多的工作,现在正在运行到这个

[UITableViewSectionElement numberOfSections]: unrecognized selector sent to instance 0xa285d50 

在这个视图控制器中有两个UITableViews 。 其中之一就是IB(datasource and delegate) 。 第二个在代码中实例化,其数据源/委托也指向视图控制器。 我在第二个tableview上放置了一个标签2来区分它们。 UITableViewTwo添加到UIView作为第一个tableview的页脚返回,如果我有有效的数据显示。 再一次,这段代码在一段时间内没有任何崩溃的情况下运行得很完美,我似乎无法弄清楚为什么现在崩溃了。 我正在使用ARC。

这里是一些代码:

当我检查发送给select器的对象的地址是:它确实是一个UITableViewSectionElement 。 为什么H这是接到号码的电话号码? 是不是应该是numberOfSectionsInTableView

 UITableView Delegate/DataSource methods -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (tableView.tag == 0) { if (indexPath.row == 0) { PCFCustomNumberReviewsCell *cell = [self.tableViewOne dequeueReusableCellWithIdentifier:@"PCFNumberOfRatings"]; [cell.numberOfReviews setText:[NSString stringWithFormat:@"%d", numReviews.integerValue]]; [cell.numberOfReviews setFont:[PCFFontFactory droidSansFontWithSize:17]]; [cell.numberOfReviews setTextColor:[UIColor lightGrayColor]]; UIImageView *imgView = [[UIImageView alloc] initWithFrame:cell.frame]; [imgView setImage:[UIImage imageNamed:@"1slot2.png"]]; [cell setBackgroundView:imgView]; return cell; }else if(indexPath.row == 1) { PCFCustomReviewCell *cell = [self.tableViewOne dequeueReusableCellWithIdentifier:@"RateEasiness"]; [cell.stars setBackgroundImage:[self getImageForStars:[NSString stringWithFormat:@"%d", totalEasiness.integerValue]] forState:UIControlStateNormal]; UIImageView *imgView = [[UIImageView alloc] initWithFrame:cell.frame]; [imgView setImage:[UIImage imageNamed:@"1slot2.png"]]; [cell setBackgroundView:imgView]; return cell; }else if(indexPath.row == 2) { PCFCustomReviewCell *cell = [self.tableViewOne dequeueReusableCellWithIdentifier:@"RateUsefulness"]; [cell.stars setBackgroundImage:[self getImageForStars:[NSString stringWithFormat:@"%d", totalUsefulness.integerValue]] forState:UIControlStateNormal]; UIImageView *imgView = [[UIImageView alloc] initWithFrame:cell.frame]; [imgView setImage:[UIImage imageNamed:@"1slot2.png"]]; [cell setBackgroundView:imgView]; return cell; }else if(indexPath.row == 3) { PCFCustomReviewCell *cell = [self.tableViewOne dequeueReusableCellWithIdentifier:@"RateFunness"]; [cell.stars setBackgroundImage:[self getImageForStars:[NSString stringWithFormat:@"%d", totalFunness.integerValue]] forState:UIControlStateNormal]; UIImageView *imgView = [[UIImageView alloc] initWithFrame:cell.frame]; [imgView setImage:[UIImage imageNamed:@"1slot2.png"]]; [cell setBackgroundView:imgView]; return cell; }else if(indexPath.row == 4) { PCFCustomReviewCell *cell = [self.tableViewOne dequeueReusableCellWithIdentifier:@"RateInterestLevel"]; [cell.stars setBackgroundImage:[self getImageForStars:[NSString stringWithFormat:@"%d", totalInterestLevel.integerValue]] forState:UIControlStateNormal]; UIImageView *imgView = [[UIImageView alloc] initWithFrame:cell.frame]; [imgView setImage:[UIImage imageNamed:@"1slot2.png"]]; [cell setBackgroundView:imgView]; return cell; }else if(indexPath.row == 5) { PCFCustomReviewCell *cell = [self.tableViewOne dequeueReusableCellWithIdentifier:@"RateTexbookUse"]; [cell.stars setBackgroundImage:[self getImageForStars:[NSString stringWithFormat:@"%d", totalTextbookUse.integerValue]] forState:UIControlStateNormal]; UIImageView *imgView = [[UIImageView alloc] initWithFrame:cell.frame]; [imgView setImage:[UIImage imageNamed:@"1slot2.png"]]; [cell setBackgroundView:imgView]; return cell; }else if(indexPath.row == 6) { PCFCustomReviewCell *cell = [self.tableViewOne dequeueReusableCellWithIdentifier:@"RateOverall"]; [cell.stars setBackgroundImage:[self getImageForStars:[NSString stringWithFormat:@"%d", totalOverall.integerValue]] forState:UIControlStateNormal]; UIImageView *imgView = [[UIImageView alloc] initWithFrame:cell.frame]; [imgView setImage:[UIImage imageNamed:@"1slot2.png"]]; [cell setBackgroundView:imgView]; return cell; } }else { PCFCustomCourseCommentCell *cell = (PCFCustomCourseCommentCell *) [self.tableViewTwo dequeueReusableCellWithIdentifier:@"PCFCourseCommentCell"]; if (cell == nil) { NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"PCFCustomCourseReviewCell" owner:self options:nil]; cell = [topLevelObjects objectAtIndex:0]; } UIImageView *imgView = [[UIImageView alloc] initWithFrame:cell.frame]; [imgView setImage:[UIImage imageNamed:@"1slot2.png"]]; [cell setBackgroundView:imgView]; PCFRateModel *rateObject = [courseReviews objectAtIndex:indexPath.section]; [cell.userName setText:rateObject.username]; [cell.date setText:rateObject.date]; [cell.professor setText:rateObject.course]; [cell.comment setText:rateObject.message]; [cell.term setText:rateObject.term]; for (UIView *view in cell.contentView.subviews) { if ([view isMemberOfClass:[UILabel class]]) { UILabel *tempLabel = (UILabel *)view; if ([tempLabel tag] != 0) { [tempLabel setFont:[PCFFontFactory droidSansFontWithSize:tempLabel.tag]]; } } } CGSize size = [rateObject.message sizeWithFont:[PCFFontFactory droidSansFontWithSize:11] constrainedToSize:CGSizeMake(290, 100000)]; [cell.comment setFrame:CGRectMake(cell.comment.frame.origin.x, cell.comment.frame.origin.y, size.width, size.height)]; [cell.comment setBaselineAdjustment:UIBaselineAdjustmentAlignBaselines]; [cell.comment setPreferredMaxLayoutWidth:290]; [cell.comment setLineBreakMode:NSLineBreakByWordWrapping]; [cell.starFunness setBackgroundImage:[self getImageForStars:rateObject.totalClarity] forState:UIControlStateNormal]; [cell.starEasiness setBackgroundImage:[self getImageForStars:rateObject.totalEasiness] forState:UIControlStateNormal]; [cell.starUsefulness setBackgroundImage:[self getImageForStars:rateObject.totalHelpfulness] forState:UIControlStateNormal]; [cell.starInterestLevel setBackgroundImage:[self getImageForStars:rateObject.totalInterestLevel] forState:UIControlStateNormal]; [cell.starOverall setBackgroundImage:[self getImageForStars:rateObject.totalOverall] forState:UIControlStateNormal]; [cell.starTextbookUse setBackgroundImage:[self getImageForStars:rateObject.totalTextbookUse] forState:UIControlStateNormal]; return cell; } } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (tableView.tag == 0) { if (isLoading == YES) { return 0; }else { return 7; } }else { if (isLoadingComments == NO && courseReviews) { return 1; }else { return 0; } } } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { if (isLoading == YES) return 0; if (tableView.tag != 0) return courseReviews.count; return 1; } -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { if (section == 0 && tableView.tag == 0) { if (isLoading == YES) { return activityIndicator; }else if (isLoading == NO) { if (isLoadingComments == NO && courseReviews.count > 0) { UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, tableViewTwo.frame.size.height)]; [view addSubview:tableViewTwo]; return view; }else if (isLoadingComments == YES){ UIView *subView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)]; UIActivityIndicatorView *view = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(145, 10, 36, 36)]; [view setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhiteLarge]; [view setColor:[UIColor whiteColor]]; [view startAnimating]; [subView addSubview:view]; return subView; }else if (!courseReviews) { UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 40)]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, 320, 30)]; [label setTextColor:[UIColor whiteColor]]; [label setTextAlignment:NSTextAlignmentCenter]; [label setFont:[PCFFontFactory droidSansFontWithSize:22]]; [label setText:@"No Reviews"]; [label setBackgroundColor:[UIColor clearColor]]; [view addSubview:label]; return view; } } } return nil; } -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { if (tableView.tag == 0) { if (isLoadingComments == NO && courseReviews.count > 0) return tableViewTwo.frame.size.height + 50; } return 5; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (tableView.tag == 2) { PCFRateModel *model = [courseReviews objectAtIndex:indexPath.section]; CGSize size = [model.message sizeWithFont:[PCFFontFactory droidSansFontWithSize:11] constrainedToSize:CGSizeMake(290, 100000)]; return (93 + size.height + 10); }else { return tableView.rowHeight; } } -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { if (section == 0 && tableView.tag == 0) { if ([PCFInAppPurchases boughtRemoveAds] == NO) { if (adView && adView.hidden == NO) { UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 80)]; CGRect frame = adView.frame; frame.origin.y = 0; adView.frame = frame; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, 320, 30)]; [label setNumberOfLines:0]; [label setText:classTitle]; [label setFont:[PCFFontFactory droidSansFontWithSize:14]]; [label setTextColor:[UIColor whiteColor]]; [label setBackgroundColor:[UIColor clearColor]]; [view addSubview:adView]; [view addSubview:label]; return view; } }else { UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 320, 30)]; [label setNumberOfLines:0]; [label setText:classTitle]; [label setFont:[PCFFontFactory droidSansFontWithSize:14]]; [label setTextColor:[UIColor whiteColor]]; [label setBackgroundColor:[UIColor clearColor]]; return label; } } return nil; } -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { if (section == 0 & tableView.tag == 0) { if ([PCFInAppPurchases boughtRemoveAds] == NO) { if (adView && adView.hidden == NO) { return 90; }return 10; }else { return 30; } } return 5; } 

查看加载(相关信息):

  tableViewTwo = [[UITableView alloc] initWithFrame:CGRectMake(0, 50, 320, self.view.bounds.size.height) style:UITableViewStyleGrouped]; [tableViewTwo setSectionFooterHeight:0.0f]; [tableViewTwo setDataSource:self]; [tableViewTwo setDelegate:self]; [tableViewTwo setTag:2]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, 320, 30)]; [label setTextColor:[UIColor whiteColor]]; [label setTextAlignment:NSTextAlignmentCenter]; [label setFont:[PCFFontFactory droidSansFontWithSize:22]]; [label setText:@"User Reviews"]; [label setBackgroundColor:[UIColor clearColor]]; [tableViewTwo setTableHeaderView:label]; [tableViewTwo setRowHeight:136]; [tableViewTwo setSectionFooterHeight:.01f]; [tableViewTwo setSectionHeaderHeight:.01f]; 

我附上了一些应用程序的截图:

每当我点击或尝试滚动tableviewTwo我得到这个崩溃。

应用图像TB2崩溃日志1崩溃日志2性能

更新:

断点

这是我滚动第二个UITableView (所有例外启用)时显示的内容:

第一行显示点击继续后

我有一个完美的工作在我的手机上(一个月前)的构build..我不知道为什么现在我得到这个错误。 如果Interface Builder造成这种情况,可以改变吗? 我已经检查了所有的网点,并将其包含在内。 谢谢..

更新:

奇怪的是,当我在另一台笔记本电脑上克隆回购时,它的工作没有问题。 我想不知道我使用的这个项目是否被破坏? 我会回家进一步调查。

任何想法,为什么这不是在我的工作笔记本电脑(类似规格)崩溃,崩溃在我的笔记本电脑上。 我克隆了这两个笔记本电脑的git目录,我在这里崩溃,但不是在那里。 我在我的笔记本电脑上运行XCode版本4.6.3。

更新2:

这不再是我的工作笔记本电脑..WFF正在进行? Xcode 4.6.3中有错误吗? 有什么我可以做的进一步解决这个问题? 为什么numberOfSections被调用? 我无法在任何地方在网上find文件。

更新3:

好吧,事实certificate,viewForFooterInSectionselect器中的这一行代码是罪魁祸首:

 UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, tableViewTwo.frame.size.height)]; [view addSubview:tableViewTwo]; return view; 

它在设备上正常工作,但在模拟器上崩溃。 当我只是改变它以下..它的作品。

 return tableViewTwo; 

有谁知道为什么在视图中返回tableview是给出一个错误?

numberOfSectionsUITableView上的一个方法 – 它不是委托方法。 它看起来像系统内部调用这个方法,出于某种原因你的表被自动释放(因此崩溃)。

我会在viewForFooterInSection方法中尝试以下内容:

 static UIView *view = nil; if (!view) { view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, tableViewTwo.frame.size.height)]; [view addSubview:tableViewTwo]; } return view; 

你刚刚提到你正在使用ARC,所以你让你的第二个TableView强大的属性? 这是一个伊娃吗?

问题是,如果你没有成为一个强大的财产,它最终会得到释放感谢ARC,你将无法得知这个问题,你可以从.h文件发布代码?