heightForRowAtIndexPath
대리자 메서드에서 detailTextLabel
높이를 반환하려고합니다. 이 방법으로 내 테이블 뷰 셀은 내 detailTextLabel
과 동일한 높이 여야합니다.올바른 높이 UITableViewCell 설정
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *text = cell.detailTextLabel.text;
CGSize size = cell.detailTextLabel.bounds.size;
UIFont *font = cell.detailTextLabel.font;
CGSize labelSize = [text sizeWithFont:font
constrainedToSize:size
lineBreakMode:UILineBreakModeWordWrap];
return labelSize.height;
}
그러나 나는 다음 줄에 EXC_BAD_ACCESS
을 받고 있어요 : 위의 코드 조각 문제
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
WATS를?
'-tableView : cellForRowAtIndexPath :'중에'-tableView : heightForRowAtIndexPath :'가 호출되므로'-cellForRowAtIndexPath :'를 호출하면 셀이 아직 완전히 생성되지 않아 참조 할 수 없습니다. –
[tableView의 cell.textLabel.text에 액세스하는 방법 : heightForRowAtIndexPath : tableView : cellForRowAtIndexPath :] (http://stackoverflow.com/questions/3903136/how-to-access-cell-textlabel-text-in) 탭에서 열어서 표출하는 경로와 탭에서의 경로) – jrturton