-1
可能重複:
Setting custom UITableViewCells heightUITablecell HIGHT的動態大小
我有其中包含的tableview定製cells.I有一個包含上表cells.But要顯示的文本對象文本的大小可能會有所不同,因此,根據內容尺寸電池的尺寸應該增加還是decreased.How做到這一點?
可能重複:
Setting custom UITableViewCells heightUITablecell HIGHT的動態大小
我有其中包含的tableview定製cells.I有一個包含上表cells.But要顯示的文本對象文本的大小可能會有所不同,因此,根據內容尺寸電池的尺寸應該增加還是decreased.How做到這一點?
首先計算根據您的text
的cell
需要sizeHeight。
CGSize boundingSize = CGSizeMake(220.0, 500);
//Adjust your Font name and size according to you
CGSize requiredSize = [cell.txtViewDescription.text sizeWithFont:[UIFont fontWithName:@"Helvetica" size:13.0] constrainedToSize:boundingSize lineBreakMode:UILineBreakModeWordWrap];
CGFloat requiredHeight = requiredSize.height;
requiredHeight = requiredHeight + 20.0;
現在用這個方法來分配cell Height
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
這只是一個想法。現在所有的東西都依賴於你的邏輯。祝你好運!
很多環節都在那裏。像[此](http://www.cimgf.com/2009/09/23/uitableviewcell-dynamic-height/)例如。順便說一句,你需要接受更多的答案。您率爲0% – FluffulousChimp
太多的討論已可用於這個問題 – cancerian