2012-02-06 2 views
1

테이블보기가 있습니다 .i 글꼴 크기를 줄이고 문자 길이를 5 자로 자르고 cell.detailTextLabel.text .cud u guys help me out. . 코드는 다음과 같습니다.글꼴 크기를 줄이고 ios tableview에서 텍스트 레이블을 자르는 방법

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 
    //NSInteger SectionRows=[tableView1 numberOfRowsInSection:indexPath.section]; 
    //NSInteger Row=indexPath.row; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) 
    { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease]; 
    } 
    //cell.imageView.backgroundColor=[UIColor clearColor]; 
    cell.selectionStyle=UITableViewCellSelectionStyleNone; 
    cell.textLabel.text=[listOfItems objectAtIndex:indexPath.row]; 
    cell.textLabel.backgroundColor=[UIColor clearColor]; 
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator; 

    if (indexPath.row == 3) 
    { 
     [email protected]"Aktiviteter"; 
    } 
    if (indexPath.row == 4) 
    { 
     cell.textLabel.textColor=[UIColor purpleColor]; 
     [email protected]"Läs mer om Allegra"; 
    } 
    if (indexPath.row == 5) 
    { 
     starImage.image = [UIImage imageNamed:@"add.png"]; 
     [cell.contentView addSubview:starImage]; 
    } 

    return cell; 
} 

답변

2

작은 글꼴을 설정하여 detailTextLabel의 글꼴 크기를 줄일 수 있습니다. 크기가 다른 일부 글꼴을 설정할 수도 있습니다.

NSString *text = @"Aktiviteter"; 
text = [text substringToIndex:5]; 
cell.detailTextLabel.text = text; 

를 그래서이 답변이 문제를 해결 되었습니까

if (indexPath.row == 3) { 
    cell.detailTextLabel.font = [UIFont systemFontOfSize:([UIFont systemFontSize]-2)]; 
    NSString *text = @"Aktiviteter"; 
    text = [text substringToIndex:5]; 
    cell.detailTextLabel.text = text; 
} 
+0

처럼 될 것이다, 다음과 같이

cell.detailTextLabel.font = [UIFont systemFontOfSize:([UIFont systemFontSize]-2)]; 

만 할 문자열의 처음 5 개 문자를 표시하려면? – Ilanchezhian

+0

감사합니다 사람이 일한 .. – stephensam

관련 문제