使用hpgrowingtextview調整textview的大小。
,並使用EditableViewCell 細胞尺寸調整基於文本大小
OR爲可編輯的tableview細胞重新加載的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);
}
我最終使用了從hpgrowingtextview,dana0550的建議和DharaParekh的解決方案派生的解決方案。然而,即時通訊問題與他們的方式蘋果重用細胞。我現在正在觀察明智的tableview框架費率。從我所看到的這可能正是我所期待的。它多大了,它仍然支持? @Matt – ScottOBot
不知道多大年紀,但它目前非常活躍。您應該可以通過在論壇中查找舊帖子或向該聊天室的人詢問。我已經使用了近一年了,我真的很開心。 – Matt
順便說一句,感謝hpgrowingtextview,我會檢查一下! :) – Matt