글쎄, 이건 오후에 들었지만, 알아 냈다고 생각해. 내가 알 수있는 한, 이것은 UITableViewCell이 textLabel 및 detailTextLabel을 레이아웃하는 방법에 버그가있는 것으로 보입니다. 행 높이를 설정하면 두 레이블에 같은 높이를 할당하는 것처럼 보입니다. 즉, detailTextLabel에 더 많은 공간이 필요하지만 위에서 보았던 동작을 정확히 수행한다는 의미입니다. 이 문제를 해결하기 위해 내가 한 두 가지는 다음과 같습니다. 그것을 해결하기 위해 UITableViewCell을 하위 클래스에 추가해야했지만 최소한의 코드가 필요했습니다.
먼저 각 행의 높이를 올바르게 계산했는지 확인하십시오. 이 메서드를 테이블 뷰 대리자에 넣습니다. 자신과 글꼴 방법을 바꾸기 :
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellDetailText = [[self itemForIndexPath: indexPath] detailDescription];
NSString *cellText = [[self itemForIndexPath: indexPath] description];
// The width subtracted from the tableView frame depends on:
// 40.0 for detail accessory
// Width of icon image
// Editing width
// I don't think you can count on the cell being properly laid out here, so you've
// got to hard code it based on the state of the table.
CGSize constraintSize = CGSizeMake(tableView.frame.size.width - 40.0 - 50.0, CGFLOAT_MAX);
CGSize labelSize = [cellText sizeWithFont: [self cellTextLabelFont] constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap];
CGSize detailSize = [cellDetailText sizeWithFont: [self cellDetailTextLabelFont] constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap];
CGFloat result = MAX(44.0, labelSize.height + detailSize.height + 12.0);
return result;
}
그런 다음, 서브 클래스있는 UITableViewCell 및 오버라이드 (override) layoutSubviews :
#import "UITableViewCellFixed.h"
@implementation UITableViewCellFixed
- (void) layoutSubviews {
[super layoutSubviews];
self.textLabel.frame = CGRectMake(self.textLabel.frame.origin.x,
4.0,
self.textLabel.frame.size.width,
self.textLabel.frame.size.height);
self.detailTextLabel.frame = CGRectMake(self.detailTextLabel.frame.origin.x,
8.0 + self.textLabel.frame.size.height,
self.detailTextLabel.frame.size.width,
self.detailTextLabel.frame.size.height);
}
@end
자막 텍스트가 셀의 맨 아래로 흐르고 다음으로 보입니다.이게 내가 본 것입니까? 또한,이 장치 또는 시뮬레이터에서 발생합니까? – jbrennan
heightForRowAtIndexPath 구현을 게시 할 수 있습니까? –
스크린 샷을 멋지게 터치하십시오. –