UITableView从情节提要加载错误的原型单元

UITableView从情节提要加载错误的原型单元,uitableview,uistoryboard,Uitableview,Uistoryboard,我有一个非常奇怪的错误,我无法理解,我现在真的需要一些帮助。基本上,tableView有三个UITableViewCell子类,它们有自己的原型单元,并出现在自己的部分中。但第三节中的原型也出现在第二节中。奇怪的是,在我的代码中加入了一些nslog之后,出现在第二节(应该在第三节)中的单元格是UITableViewCell的正确子类,但另一个原型的内容却出现了。我不知道为什么会这样。我必须检查以确保原型是正确的子类,标识符都是正确的,它们是正确的。以前有人遇到过这个问题吗?很抱歉,我的cellF

我有一个非常奇怪的错误,我无法理解,我现在真的需要一些帮助。基本上,tableView有三个UITableViewCell子类,它们有自己的原型单元,并出现在自己的部分中。但第三节中的原型也出现在第二节中。奇怪的是,在我的代码中加入了一些nslog之后,出现在第二节(应该在第三节)中的单元格是UITableViewCell的正确子类,但另一个原型的内容却出现了。我不知道为什么会这样。我必须检查以确保原型是正确的子类,标识符都是正确的,它们是正确的。以前有人遇到过这个问题吗?很抱歉,我的
cellForRowAtIndexPath:
方法使用了多长时间:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    WaveDetailCell *waveDetails;
    ActionsCell *actions;
    CommentCell *comments;
    id cellToReturn;

    if (self.hasAgrees || self.hasComments)
    {
        switch (indexPath.section)
        {
            case 0:
            {
                waveDetails = [tableView dequeueReusableCellWithIdentifier:WaveDetailCellIdentifier forIndexPath:indexPath];

                if ([waveDetails.waveLabel respondsToSelector:@selector(setAttributedText:)])
                {
                    NSString *name = self.currentWaveObject.wavedToUserID;
                    NSString *fullWaveString = [name stringByAppendingString:self.currentWaveObject.waveString];
                    NSRange range = [fullWaveString rangeOfString:self.currentWaveObject.wavedToUserID];
                    UIFont *font = [UIFont fontWithName:HelveticaMedium size:16.0f];
                    NSDictionary *attrs = @{NSFontAttributeName: font};
                    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:fullWaveString];
                    [attributedString addAttributes:attrs range:range];
                    [waveDetails.waveLabel setAttributedText:attributedString];
                }

                waveDetails.wavedByNameLabel.text = self.currentWaveObject.wavedByUserID;
                waveDetails.timestampLabel.text = self.currentWaveObject.creationDate;

                //round the corners of the imageview
                [self setCornerRadiusForImageView:waveDetails.profilePicImageView withRadius:CGSizeMake(4.0f, 4.0f)];
                [self setCornerRadiusForImageView:waveDetails.waverProfileImageView withRadius:CGSizeMake(2.0f, 2.0f)];
                cellToReturn = waveDetails;
            }
                break;

            case 1:
            {
                if (self.hasAgrees)
                {
                    //create agrees cell
                }
                else
                {
                    actions = [tableView dequeueReusableCellWithIdentifier:ActionsCellIdentifier forIndexPath:indexPath];
                    cellToReturn = actions;
                }
            }

            case 2:
            {
                if (self.hasAgrees)
                {
                    //if there are agrees, and no comments, then the last section should be the actions cell
                    actions = [tableView dequeueReusableCellWithIdentifier:ActionsCellIdentifier forIndexPath:indexPath];
                    cellToReturn = actions;
                }
                else
                {
                    //there are comments, and no agrees
                    comments = [tableView dequeueReusableCellWithIdentifier:CommentCellIdentifier forIndexPath:indexPath];
                    CommentObject *comment = [self.currentWaveObject.commentsArray objectAtIndex:indexPath.row];
                    comments.userNameLabel.text = comment.commenterID;
                    comments.commentLabel.text = comment.commentText;
                    comments.timeStampLabel.text = comment.timeStamp;
                    [self setCornerRadiusForImageView:comments.userImageView withRadius:CGSizeMake(3.0f, 3.0f)];
                    cellToReturn = comments;
                }
            }

            default:
                break;
        }
    }
    else if (self.hasComments && self.hasAgrees)
    {
        switch (indexPath.section)
        {
            case 0:
            {
                waveDetails = (WaveDetailCell *)[tableView dequeueReusableCellWithIdentifier:WaveDetailCellIdentifier forIndexPath:indexPath];

                if ([waveDetails.waveLabel respondsToSelector:@selector(setAttributedText:)])
                {
                    NSString *name = self.currentWaveObject.wavedToUserID;
                    NSString *fullWaveString = [name stringByAppendingString:self.currentWaveObject.waveString];
                    NSRange range = [fullWaveString rangeOfString:self.currentWaveObject.wavedToUserID];
                    UIFont *font = [UIFont fontWithName:HelveticaMedium size:16.0f];
                    NSDictionary *attrs = @{NSFontAttributeName: font};
                    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:fullWaveString];
                    [attributedString addAttributes:attrs range:range];
                    [waveDetails.waveLabel setAttributedText:attributedString];
                }

                waveDetails.wavedByNameLabel.text = self.currentWaveObject.wavedByUserID;
                waveDetails.timestampLabel.text = self.currentWaveObject.creationDate;

                //round the corners of the imageview
                [self setCornerRadiusForImageView:waveDetails.profilePicImageView withRadius:CGSizeMake(4.0f, 4.0f)];
                [self setCornerRadiusForImageView:waveDetails.waverProfileImageView withRadius:CGSizeMake(0.5f, 0.5f)];
                cellToReturn = waveDetails;
            }
                break;

            case 1:
            {
                //create agrees cell
            }
                break;

            case 2:
            {
                actions = (ActionsCell *)[tableView dequeueReusableCellWithIdentifier:ActionsCellIdentifier forIndexPath:indexPath];
                cellToReturn = actions;
            }
                break;

            case 3:
            {
                comments = (CommentCell *)[tableView dequeueReusableCellWithIdentifier:CommentCellIdentifier forIndexPath:indexPath];
                CommentObject *comment = [self.currentWaveObject.commentsArray objectAtIndex:indexPath.row];
                comments.userNameLabel.text = comment.commenterID;
                comments.commentLabel.text = comment.commentText;
                comments.timeStampLabel.text = comment.timeStamp;
                [self setCornerRadiusForImageView:comments.userImageView withRadius:CGSizeMake(2.0f, 2.0f)];
                cellToReturn = comments;
            }
                break;

            default:
                break;
        }
    }
    else
    {
        if (indexPath.row == 0)
        {
            waveDetails = (WaveDetailCell *)[tableView dequeueReusableCellWithIdentifier:WaveDetailCellIdentifier forIndexPath:indexPath];

            if ([waveDetails.waveLabel respondsToSelector:@selector(setAttributedText:)])
            {
                NSString *name = self.currentWaveObject.wavedToUserID;
                NSString *fullWaveString = [name stringByAppendingString:self.currentWaveObject.waveString];
                NSRange range = [fullWaveString rangeOfString:self.currentWaveObject.wavedToUserID];
                UIFont *font = [UIFont fontWithName:HelveticaMedium size:16.0f];
                NSDictionary *attrs = @{NSFontAttributeName: font};
                NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:fullWaveString];
                [attributedString addAttributes:attrs range:range];
                [waveDetails.waveLabel setAttributedText:attributedString];
            }

            waveDetails.wavedByNameLabel.text = self.currentWaveObject.wavedByUserID;
            waveDetails.timestampLabel.text = self.currentWaveObject.creationDate;

            //round the corners of the imageviews
            [self setCornerRadiusForImageView:waveDetails.profilePicImageView withRadius:CGSizeMake(4.0f, 4.0f)];
            [self setCornerRadiusForImageView:waveDetails.waverProfileImageView withRadius:CGSizeMake(0.5f, 0.5f)];
            cellToReturn = waveDetails;
        }
        else
        {
            actions = (ActionsCell *)[tableView dequeueReusableCellWithIdentifier:ActionsCellIdentifier forIndexPath:indexPath];
            cellToReturn = actions;
        }
    }
    return cellToReturn;
}

等等,我知道了。这很尴尬,但我在switch语句中的一个案例中忘记了一个
中断