다양한 행 높이로 UITableView를 만들고 싶습니다. UITableViewCell 내부에 UILabels를 만들어이 작업을 수행하려고합니다.변수 UITableCellView 하위보기가있는 높이
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"EntryCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
}
UILabel *textView = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 300, 40)];
textView.numberOfLines = 0;
textView.text = [entries objectAtIndex:[indexPath row]];
[cell.contentView addSubview:textView];
[textView release];
return cell;
}
이 나에게 셀 당 텍스트의 2 개 라인을 제공합니다
여기에 지금까지 내 코드입니다. 그러나 각 "항목"줄 수를 다른 있고 UITableViewCells 글꼴 크기를 변경하지 않고 필요에 따라 텍스트를 배치하는 자동으로 크기를 조정하려면.[textView sizeToFit]
및/또는 [cell sizeToFit]
이 작동하지 않는 것 같습니다.
----------------
Lorem ipsum
----------------
Lorem ipsum
Lorem ipsum
----------------
Lorem ipsum
Lorem ipsum
Lorem ipsum
----------------
Lorem ipsum
----------------
Lorem ipsum
Lorem ipsum
----------------
사람이 제대로이 작업을 수행하는 방법을 알고 있나요 : 나는 jQuery과보고 싶은 방법은 다음과
이야?
감사합니다.
감사합니다. sizeWithFont 대신에 sizeToFit을 사용했습니다. –
Fwiw, v2ex.com 링크가 죽었습니다. 도메인이 엉망이 된 것처럼 보입니다. –