在UITableViewCell上建立UILable多行显示

来源:互联网 发布:linux运维工程师简历 编辑:程序博客网 时间:2024/05/21 06:12

- (UITableViewCell *)tableView:(UITableView *)tableViewcellForRowAtIndexPath:(NSIndexPath *)indexPath {
    staticNSString *CellIdentifier =@"Cell";   
   UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell ==nil) {
       cell = [[[UITableViewCell alloc] initWithFrame:CGRectZeroreuseIdentifier:CellIdentifier] autorelease];
  UILabel *Datalabel = [[UILabelalloc] initWithFrame:CGRectMake(10, 0, 320, 44)];
  [DatalabelsetTag:100];
  Datalabel.autoresizingMask =UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight;
  [cell.contentViewaddSubview:Datalabel];
  [Datalabel release];
 
 UILabel *Datalabel = (UILabel *)[cell.contentViewviewWithTag:100];
 [Datalabel setFont:[UIFontboldSystemFontOfSize:18]];
 Datalabel.text = [data.DataArrayobjectAtIndex:indexPath.row];
 cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
    returncell;
}