使用hpgrowthtextview调整文本视图的大小。
并使用EditableViewCell
根据文本大小调整单元格大小
或用于可编辑的表格视图单元格
编写以下方法来重新加载uitableview的数据。为此,您将自定义单元格用于 uitableview。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [arrChatMessage count];
}
-(CGFloat)tableView:(UITableView *)aTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *textc1 = [arrChatMessage objectAtIndex:indexpath.row];
CGSize constraintc1 = CGSizeMake(320, 2000);
//320 means width of your label in which you want to display chat message
CGSize sizec1 = [textc1 sizeWithFont:[UIFont fontWithName:@"Arial-BoldMT" size:12.0] constrainedToSize:constraintc1 lineBreakMode:UILineBreakModeWordWrap];
//font and font size of your label in which you want to display chat message
return sizec1.height;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
ChatListCustomCell *cell = (ChatListCustomCell *)[tblChatList dequeueReusableCellWithIdentifier:@"ChatListCustomCell"];
if (cell != nil)
cell = nil;
NSArray* nib = [[NSBundle mainBundle] loadNibNamed:@"ChatListCustomCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
cell.showsReorderControl = NO;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.backgroundColor=[UIColor clearColor];
//..............
NSString *textc1 = [arrChatMessage objectAtIndex:indexpath.row];
CGSize constraintc1 = CGSizeMake(320, 2000);
//320 means width of your label in which you want to display chat message
CGSize sizec1 = [textc1 sizeWithFont:[UIFont fontWithName:@"Arial-BoldMT" size:12.0] constrainedToSize:constraintc1 lineBreakMode:UILineBreakModeWordWrap];
//font and font size of your label in which you want to display chat message
cell.lblChatMessage.text = [arrChatMessage objectAtIndex:indexpath.row];
cell.lblChatMessage.frame = CGRectMake(0,0,320,sizec1.height);
}