autolayout을 사용하지 않는 스토리 보드 내에서 사용자 정의 셀 프로토 타입을 설정했고 UIImageView가 셀 내부에있는 모든 문제를 해결할 수 있습니다. 내가 패딩의 비트와 함께 세포의 크기를 반영하고 싶을 때 소유. 여기 UIImageView 자동으로 다양한 높이로 사용자 정의 UITableViewCell 안에 크기 조정
는 스토리 보드 인터페이스 빌더와보기 모드의 설정이 여기을 "규모 채우기 위해"로 설정되어 것은 내가없이 배치의 편집이나 스케일링으로 돌아갈 것입니다 이미지, 마치 애스펙트 채우기를 사용하는 것처럼 보입니다.
나는 다양한 옵션을 시도하고 아무도 지금까지 나를 위해 제대로 작동하지, 내가 생각할 수있는 유일한 방법은 자동 크기 조정의 턴 세포가 어떤 아이디어를 만들 때 수동으로 자신을 사각형 설정은?
셀
- (void)setCell:(NSDictionary*)messageData
{
[_nameLabel setText:messageData[@"name"]];
[_messageLabel setText:messageData[@"message"]];
[_nameLabel sizeToFit];
[_messageLabel sizeToFit];
UIImage *image;
if([messageData[@"direction"] boolValue])
{
image= [[UIImage imageNamed:@"bubble_left"]resizableImageWithCapInsets:UIEdgeInsetsMake(18, 6, 6, 10) resizingMode:UIImageResizingModeStretch];
}
else
{
image= [[UIImage imageNamed:@"bubble_right"]resizableImageWithCapInsets:UIEdgeInsetsMake(18, 10, 6, 6) resizingMode:UIImageResizingModeStretch];
}
[_bubbleImage setImage:image];
}
및
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CUIChatCellTableViewCell *cell = [_chatTableView dequeueReusableCellWithIdentifier:@"CustomCell" forIndexPath:indexPath];
NSDictionary *messageData = _testDataArray[indexPath.row];
[cell setCell:messageData];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
_customCell = [_chatTableView dequeueReusableCellWithIdentifier:@"CustomCell"];
//configure cell
NSDictionary *messageData = _testDataArray[indexPath.row];
[_customCell setCell:messageData];
//Get height of the cell
CGFloat height = [_customCell.messageLabel frame].size.height+[_customCell.nameLabel frame].size.height+20;
return height;
}