iosuitableviewheightforrowatindexpath

heightForRowAtIndexPath never being called iOS9


Alright I'm pretty certain this method has always been executing until now for my UITableViewController. I have print statements in my method like so:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //455(PERFECT MIN HEIGHT) 475 is perfect spacing. 15.5 is the scalar for when descriptionLabel expands lines
    return 475;
    NSLog(@"ISSSS ITTT ONNNN???");

    if (currentDescriptionHeight == 16.0) {
        NSLog(@"OHHH so it triggered 1111");
        return 475;
    }else if (currentDescriptionHeight == 31.5){
        NSLog(@"OHHH so it triggered 2222");
        return 490.5;
    }else if (currentDescriptionHeight == 47){
        NSLog(@"OHHH so it triggered 3333");
        return 506;
    }

    //475 - 1 line description,
}

I have copied the method header into my .h file, and have correctly set the delegation with:

self.tableView.delegate = self;
self.tableView.dataSource = self;

in my viewDidLoad: method. Why is my heightForRowAtIndexPath not being called at all?


Solution

  • You just need to move the return statement at the top of the function to the bottom or put it in an else as part of the current if statement because the return statement ends the function immediately so the code below it would never execute.