开发者

UITableView textLabels

开发者 https://www.devze.com 2023-03-11 07:17 出处:网络
I have the: cell.开发者_Go百科textLabel.text and cell.detailTextLabel.text is there a 3rd text label i can use?

I have the:

cell.开发者_Go百科textLabel.text and cell.detailTextLabel.text

is there a 3rd text label i can use?

Aim:

to show the 2 above text labels + a text label on the right.

Is there a way of doing this without creating a custom tableViewCell?

sam


No, there are only these two. If you want to have more you have to create a custom cell.

You can find this information also in the class reference of UITableViewCell.


You can add the view(s) you need directly to the UITableViewCell

UILabel *myLabel = /* create and configure the label */
[myCell.contentView addSubview:myLabel];


You can use cell.accessoryview and add a text label into that i think.


  • (UITableViewCell *) getCellContentView:(NSString *)cellIdentifier{
    static NSString *CellIdentifier = @"Cell";
    UILabel *l1;
    UITableViewCell *cell=[[[UITableViewCell alloc]initWithFrame: CGRectMake(0, 0, 300, 60) reuseIdentifier:CellIdentifier] autorelease];
l1=[[UILabel alloc] initWithFrame:CGRectMake(100.0, 15.0, 400.0, 40.0)];
l1.tag=1;
l1.font=[UIFont fontWithName:@"AppleGothic" size:17];
//  l1.font=[UIFont boldSystemFontOfSize:20];
l1.textColor=[UIColor blackColor];
l1.backgroundColor=[UIColor clearColor];
l1.lineBreakMode =UILineBreakModeWordWrap;
l1.numberOfLines=3;
[cell.contentView addSubview:l1];
[l1 release];

l1=[[UILabel alloc]initWithFrame:CGRectMake(110.0, 35.0, 650.0, 45.0)];
l1.tag =2;
l1.font=[UIFont fontWithName:@"Futura-MediumItalic" size:13];
l1.textColor=[UIColor grayColor];
l1.numberOfLines=3;
l1.backgroundColor=[UIColor clearColor];
l1.lineBreakMode =UILineBreakModeWordWrap;
[cell.contentView addSubview:l1];
[l1 release];




return cell;

}

and then call cellforrowatindexpath method UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    cell=[self getCellContentView:CellIdentifier];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号