uitableviewcell textlabel слишком длинный и выталкивает detailtextlabel из поля зрения

Когда я использую UITableViewCellStyleValue1, я получил длинную строку textLabel, и каким-то образом детальTextLabel вытолкнулась из представления.

Когда я закоротил мой текст textLabel, тогда я могу увидеть текст detailTextLabel.

Можно ли каким-либо образом ограничить ширину textLabel в указанном выше стиле, чтобы он обрезал textLabel, если он слишком длинный?

Мой код:

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

, поэтому имя моей валюты будет длинным в некоторых записях .

28
задан lucas 21 April 2011 в 15:35
поделиться