2010-08-08 30 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