Reputation: 53
I have a UITableView inside of a View created from a NIB. the table has one section containing 6 rows and 1 footer. when i use:
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 80;
}
to return the height of the footer, which is being loaded from the same NIB. the UITableViewCell in the nib has a height of 80. the UITableViewCells are assigned using this code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0){ if (indexPath.row == 0){ return companyCell; }
if (indexPath.row == 1){ return firstNameCell; } if (indexPath.row == 2){ return lastNameCell; } if (indexPath.row == 3){ return emailCell; } if (indexPath.row == 4){ return passwordCell; } if (indexPath.row == 5){ return passwordConfirmCell; } }
return passwordConfirmCell;
}
i get a white line at the bottom of my table like the image at http://swnsn.com/white.png
if i return a footer height of 79, or 81, the white line goes away and the UITableViewCell scales to the width of the window
any thoughts?
Upvotes: 1
Views: 1461
Reputation: 53
I figured it out!! I was passing an instance of UITableViewCell to the footer. i have update my code to only pass a UIView and the problem has been resolved!
Upvotes: 3
Reputation: 1101
Have you tried more row manipulation like this in terms of it's height?
- (CGFloat)tableView:(UITableView *) theTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
Question *question = [self.questions objectAtIndex:row];
NSString *theText = question.description;
UIFont *font = [UIFont fontWithName:@"Helvetica" size:14.0]; // You can choose a different font ofcourse.
int heightExtra = 0;
if (selectedIndexSegment == 0){
heightExtra = 54;
}
if (selectedIndexSegment == 1) {
heightExtra = 24;
}
CGSize withinsize = CGSizeMake(theTableView.frame.size.width -60, 1000); //1000 is just a large number. could be 500 as well
// You can choose a different Wrap Mode of your choice
CGSize sz = [theText sizeWithFont:font constrainedToSize:withinsize lineBreakMode:UILineBreakModeWordWrap];
return sz.height + heightExtra; // padding space of 20 should be fine!
}
And also how about
self.tableView.separatorColor = [UIColor clearColor];
Hope it helps...
Upvotes: 1