2010-08-08 44 views
1

我在从NIB创建的视图内部有一个UITableView。该表有一个包含6行和1页脚的部分。当我使用:UITableView随机在页面返回正确大小的页脚时出现白线

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ 
    return 80; 
} 

返回页脚的高度,这是从同一个NIB加载。所述的UITableViewCell在笔尖具有80的高度UITableViewCells都采用这种代码分配:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

如果(indexPath.section == 0){ 如果(indexPath.row == 0){ 返回companyCell ; }

if(indexPath.row == 1){0} { return firstNameCell; } if(indexPath.row == 2){return lastNameCell; } if(indexPath.row == 3){0}返回emailCell; } if(indexPath.row == 4){0}返回passwordCell; } if(indexPath.row == 5){0}返回passwordConfirmCell; } }

return passwordConfirmCell; 
} 

我在http://swnsn.com/white.png

得到我的表像的图像底部的白线,如果我返回的79或81英尺的高度,白线将消失, UITableViewCell缩放至窗口的宽度

有什么想法?

+0

抱歉上面的代码格式错误。当我输入时,stackoverflow提供了一个适当的预览。 – swnsn 2010-08-08 18:11:10

+0

81px页脚的图像位于http://swnsn.com/nowhite.png – swnsn 2010-08-08 18:12:44

回答

3

我想通了!我正在将UITableViewCell的一个实例传递给页脚。我已更新我的代码只传递一个UIView,并且问题已解决!

1

你是否尝试过使用更多像这样的行操作?

- (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! 
} 

,以及如何对

self.tableView.separatorColor = [UIColor clearColor]; 

希望它可以帮助...

+1

self.tableView.separatorColor = [UIColor clearColor];也从表格中删除所有分隔符。 – swnsn 2010-08-08 20:29:29

+0

我仍然需要试用你的其他代码。 – swnsn 2010-08-08 20:30:04