uitableviewcell textlabel trop long et pousser detailtextlabel hors de la vue

Quand je suis en utilisant UITableViewCellStyleValue1, j'ai eu une longue chaîne de textLabel, et en quelque sorte le detailTextLabel ai pousser hors de la vue.

Quand j'ai court-circuité mon textLabel texte, alors je peux voir la detailTextLabel du texte.

Est-il de toute façon à limiter la largeur de textLabel dans le style précédent, de sorte qu'il va tronquer le textLabel avec c'est trop long?

Mon code est:

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

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];

}

cell.textLabel.lineBreakMode = UILineBreakModeTailTruncation;

//---get the letter in each section; e.g., A, B, C, etc.---
NSString *alphabet = [self.currencyNameIndex objectAtIndex:[indexPath section]];

//---get all states beginning with the letter---
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF beginswith[c] %@", alphabet];
self.currencyList = [self.keyCurrencyName filteredArrayUsingPredicate:predicate];

if ([self.currencyList count] > 0) 
{
    NSString *currencyName = [self.keyCurrencyName objectAtIndex:indexPath.row];
    cell.textLabel.text = currencyName;

    NSString *currencyCode = [self.valueCurrencyCode objectAtIndex:indexPath.row];
    cell.detailTextLabel.text = currencyCode;

}   

return cell;
}

donc mon nom de la devise sera long sur certaines d'entrée.

  • Il ressemble à la Figure 1-8 dans le la Vue de la Table Guide de Programmation pour iOS?
  • oui. corriger Nick. sauf que mon detailTextLabel est fixé à 3 caractères, mais le textLabel sera long donc j'ai besoin de tronquer textLabel comme dans la Figure 1-8
  • Étrange, il ne tronquée par défaut. Avez-vous mis la linebreakmode de la textLabel?
  • collé le code. oui, essayé de définir le linebreakmode aussi, mais pas de chance
  • Encore plus étrange. Pouvez-vous poster une capture d'écran? Et s'il vous plaît dump le cadre de la textLabel d'une cellule dans laquelle le texte ne pas regarder à droite.
InformationsquelleAutor lucas | 2011-04-21