0
남자. 다른 셀을 가진 UITableView가 있고 높이를 계산하는 코드가 있습니다. 한 프로젝트에서 완벽하게 작동하지만 초당 높이가 0을 반환합니다. 이 문제의 원인은 무엇입니까? 내 코드 : heightForRowAtIndexPath:
위임 방법은 cellForRowAtIndexPath:
대리자 메서드 전에 호출되는신비한 트러블에 크기가 붙어 있습니다
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
CGFloat cellWidth = 320.0f;
CGSize size = [cell.textLabel.text sizeWithFont:cell.textLabel.font constrainedToSize:CGSizeMake(cellWidth, CGFLOAT_MAX) lineBreakMode:cell.textLabel.lineBreakMode];
CGFloat height = size.height;
NSLog(@"Height: %f", height);
return height;
}
정답은 +1입니다. 먼저 heightForRowAtIndexPath가 호출되고 cellForRowAtIndexPath가 호출됩니다. 왜 OP가 나에게 미스테리가되기 전에 이것이 작동하는지 보았습니다. – Till
문제는 더 힘들다고 생각합니다. – werbary