현재 UITableViewCell에서 UILabel 높이를 조정하고 있습니다. 이제 클라이언트는 UITableViewCell에 포함 된 두 레이블을 내용에 따라 크기를 조정하려고합니다. 이를 연구하면서 단일 레이블의 크기를 조정할 수있는 솔루션을 어디에서나 볼 수 있지만 다중 레이블은 필요하지 않습니다. 누군가이 문제에 대한 좋은 자료를 알려줄 수 있습니까?UITableViewCell 여러 개의 UILabels 자동 크기 조정
0
A
답변
0
레이블 크기 조정에 대한 연구가 정확하면 하나의 레이블에만 크기 조정 논리를 작성해야합니다. 보시다시피
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
반환 유형 uitableviewcell. 각 행에 대해 정적 셀을 작성하지 않는 한 항상 셀에 대해 동일한 구성을 리턴합니다.
[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
이 메서드는 셀을 dequeue & 다시 사용합니다. 셀을 만들 때 레이블의 크기를 조정하는 논리를 올바르게 작성해야합니다. 또는 사용자 정의 셀 클래스의 크기 조정 논리를 올바르게 수정하는 것이 좋습니다. 나는이 문제에 도움이되는 코드를 추가하고있다.
CGSize maximumLabelSize = CGSizeMake(270, FLT_MAX);
CGSize expectedLabelSize = [myString sizeWithFont:[UIFont fontWithName:@"Helvetica" size:16.0f] constrainedToSize:maximumLabelSize lineBreakMode:NSLineBreakByWordWrapping];
NSLog(@"Expected Size of label based on string--%@",NSStringFromCGSize(expectedLabelSize));
//adjust the label the the new height.
CGRect newFrame = myLabel.frame;//get initial frame of your label
newFrame.size.height = expectedLabelSize.height;
myLabel.frame = newFrame;
NSLog(@"new frame of label--%@",NSStringFromCGRect(newFrame));
[myLabel setText:attString];
관련 문제
- 1. 자체 크기 조정 UITableViewCell 안에 여러 UILabels
- 2. 제스처로 UITableViewCell 크기 조정
- 3. 크기 조정 UITableViewCell
- 4. uitableviewcell 이미지 크기 조정
- 5. 여러 언어로 UILabel을 자동 크기 조정
- 6. 레이블 자동 크기 조정
- 7. 자동 레이아웃 UILabels
- 8. UITextView 및 UITableViewCell 크기 조정
- 9. UITableViewCell 내부의 UIImageView 크기 조정
- 10. UITableViewCell 프레임 문제 크기 조정
- 11. 자동 크기 조정 GtkScrolledWindow
- 12. iPhone에서보기 자동 크기 조정
- 13. 있는 UITableViewCell 내용보기 - 추가 UILabels
- 14. UICollectionView가 포함 된 크기 조정 UITableViewCell
- 15. 자동 크기 조정 방법
- 16. UITableViewCell 셀 재사용 및 UILabel 자동 레이아웃 동적 크기 조정
- 17. 아이폰 OS 8있는 UITableViewCell 크기 조정 문제
- 18. GridSplitter 자동 크기 조정
- 19. 여러 줄 자동 크기 조정 텍스트 UILabel
- 20. 자동 크기 조정 배경과 자동 크기 조정 이미지를 겹치는 방법
- 21. 내용에 맞게 UITextVIew 및 UITableViewCell 크기 조정
- 22. 자체 크기 조정 UITableViewCell iOS 8
- 23. 자동 크기 조정 CCLabelBMFont
- 24. 이미지 자동 크기 조정
- 25. 자동 크기 조정 이미지
- 26. Iframe 자동 크기 조정
- 27. 자동 크기 조정 iFrame
- 28. 자동 크기 조정 GridView
- 29. uiview의 자동 크기 조정
- 30. 정지 자동 크기 조정
autolayout을 사용합니까? 대상 ios 버전은 무엇입니까? – vokilam