Unwanted empty UITableViewCell at the top of my UITableView

I have a UITableView that has 1 empty row at the top and I can't figure out why. Here is the relevant code, do you know what is going on here?

UITableView loads without content. This method is what starts with each data update after:

- (IBAction)updateButton:(id)sender 
{
    if (questionsTextField.isFirstResponder) {
        [questionsTextField resignFirstResponder];
        [self assignQuestionsCount];
    }

    if (currentNumberOfQuestions > 0) {
        // do work calculating
        currentTest = nil;

        currentTest = [self retrieveCurrentTest];
        currentTest.numberOfQuestions = currentNumberOfQuestions;
        currentTest.decimalPlacesToDisplay = 0;
        currentTest.roundingBreakPoint = 0.5;

        currentGradeScale = nil;
        currentGradeScale = [currentTest generateGradingScale];
        [scoresTableView reloadData];
    }
    else {
        // my error handling on text boxes here....
    }
}

Here is my implementation of the UITableView methods:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.currentGradeScale count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"scoresIndentifier";
    static int missedTag = 1, correctTag = 2, gradeTag = 3;

    UILabel *missedLabel, *correctAndTotalLabel, *letterGradeLabel;

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    //if a cell does not exist, get it then initialize it
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];

        // populate data
        missedLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 100, 50)];
        missedLabel.tag = missedTag;
        missedLabel.font = [UIFont systemFontOfSize:14.0];
        missedLabel.textAlignment = UITextAlignmentCenter;
        missedLabel.textColor = [UIColor blackColor];
        missedLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight |UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth;
        [cell.contentView addSubview:missedLabel];

    }
    // if it does, just reassign the properties
    else {
        missedLabel = (UILabel *)[cell.contentView viewWithTag:missedTag];
    }

    missedLabel.text = [[self.currentGradeScale objectAtIndex:indexPath.row] determineLetterGrade:0.5];

    return cell;
}

Thanks for the help, I am very grateful.

+5
source share
2 answers

, , , , , (.. self.currentGradeScale objectAtIndex: 0 nil @ "" 0.5". )

cellForRowAtIndexPath , , / 0?

missedLabel - , .

+1

, , Scroll View Size/Content Insets/Top . . . 0 , . , .

enter image description here

+1

All Articles