2010-10-15 4 views
0

J'ai une table qui affiche la cellule en utilisant UITableViewCellStyleSubtitle:UICell Textlabel changer la taille du cadre

============================================================= 
Title:This is the title of something  Date:Custom label 
Subtitle:breif description 
============================================================= 

Mon problème est que, parfois, les titres sont plus alors la cellule et couvrent plus de la date. Donc, est-il possible de réduire cell.textlabel afin qu'il ne permette pas de couvrir la date.

Voici mon code pour la cellule

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

static NSString *CellIdentifier = @"Cell"; 



UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

if (cell == nil) { 
    cell = [[[UITableViewCell alloc] 
      initWithStyle:UITableViewCellStyleSubtitle 
      reuseIdentifier:CellIdentifier] 
      autorelease]; 

    CGRect frame; 

    if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft || self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) 
     frame.origin.x = 370; 
    else 
     frame.origin.x = 220; 

    frame.origin.y = 15; 
    frame.size.height = 15; 
    frame.size.width = 80; 

    UILabel *dateLabel = [[UILabel alloc] initWithFrame:frame]; 
    dateLabel.tag = 1; 
    [cell.contentView addSubview:dateLabel]; 
    [dateLabel release]; 
} 


    Document *d = [documentList objectAtIndex:indexPath.row]; 

    UILabel *dateLabel = (UILabel *) [cell.contentView viewWithTag:1]; 
    dateLabel.text = [d date]; 
    dateLabel.textColor = [UIColor blackColor]; 
    [dateLabel setFont:[UIFont fontWithName:@"Arial" size:12]]; 

    cell.textLabel.textColor = [UIColor blackColor]; 
    [cell.textLabel setFont:[UIFont boldSystemFontOfSize:13]]; 
    cell.textLabel.text = [d title]; 

    cell.detailTextLabel.textColor = [UIColor blackColor]; 
    [cell.detailTextLabel setFont:[UIFont fontWithName:@"Arial" size: 10]]; 
    cell.detailTextLabel.text = [d inst]; 

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 


return cell; 

}

Répondre

1

créer votre propre UITableViewCell sous-classe et organiser vos étiquettes manuellement. Actuellement, vous utilisez un type de cellule intégré (UITableViewCellStyleSubtitle), puis vous ajoutez votre sous-vue de date, ce qui place l'étiquette de titre hors de votre portée.

Questions connexes