代码: [plain] view plain copy NSString* text=@"dwqqqqqqqqqqqqqqqqq"; //初始化label UILabel *comments = [[UILabel alloc] init]; comments.text = text; //设置自动行数与字符换行 [comments setNumberOfLines:0]; UIFont *font =[UIFont fontWithName:@"Helvetica" size:13]; comments.font = font; //设置一个行高上限 CGSize constraint = CGSizeMake(280, 20000.0f); CGSize size = [text sizeWithFont:font constrainedToSize:constraint lineBreakMode:NSLineBreakByCharWrapping]; //计算实际frame大小,并将label的frame变成实际大小 [comments setFrame:CGRectMake(5,indexPath.row==2?5:1, size.width, size.height+12)]; [image addSubview:comments]; [cell.contentView addSubview:comments]; 这样就可以实现自动行数和换行了。