2013-10-15 90 views
0

嗨我有一個tableview的問題。單元格textlabel(默認原型單元格)隱藏了我背景的一部分。我不明白爲什麼以及如何改變。textviewcell標籤覆蓋我的背景

我知道我可以修復放置自己的標籤,但我想知道這裏的錯誤在哪裏。



這裏是應該的,在底部的線......作爲分隔

here is how it should be, with a line on the bottom... as a divider



但在這裏它是怎麼出來

enter image description here



這是代碼

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    icons = [NSArray arrayWithObjects: 
      @"No Icon", 
      @"Appointments", 
      @"Birthdays", 
      @"Chores", 
      @"Drinks", 
      @"Folder", 
      @"Groceries", 
      @"Inbox", 
      @"Photos", 
      @"Trips", 
      nil]; 

    rowImage = [NSArray arrayWithObjects:@"row", @"row2", @"row3", @"row4", nil]; 

    self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background"]]; 
    self.tableView.tableFooterView = [[UIView alloc] init]; 

} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

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

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

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"IconCell"]; 
    NSString *icon = [icons objectAtIndex:indexPath.row]; 

    cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[rowImage objectAtIndex:arc4random()%4]]]; 
    cell.textLabel.textColor = [UIColor redColor]; 
    cell.textLabel.bounds = CGRectMake(cell.textLabel.frame.origin.x, cell.textLabel.frame.origin.y, cell.textLabel.frame.size.width, 10); 
    cell.textLabel.frame = CGRectMake(cell.textLabel.frame.origin.x, cell.textLabel.frame.origin.y, cell.textLabel.frame.size.width, 10); 
    cell.textLabel.text = icon; 
    cell.imageView.image = [UIImage imageNamed:icon]; 
    return cell; 
} 

回答

0

嘗試下一個:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { 
    cell.textLabel.backgroundColor = [UIColor clearColor]; 
}