我需要从底部到顶部计算单元格的高度, 正如我在第一个单元格中需要其它单元格的高度总和。 如何计算第一个单元格的最后一个高度, 然后是最后一个单元格的第二个高度. 以及最后第一个单元格高度。 请帮助 。 我在这里的支架非常差。 我的代码是这样的... 它从上到下给出了高度 。
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section==0 && currentQuestion.graphic){
UIImage *img= [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:currentQuestion.graphic ofType:nil]];
self.currentQuestionImage=img;
[img release];
return (self.currentQuestionImage.size.height* [self zoomFactor])+10;
}else if ((indexPath.section==0 && !currentQuestion.graphic) || (indexPath.section==1 && currentQuestion.graphic)){
CGSize constSize = { self.view.frame.size.width, 20000.0f };
CGSize textSize = [currentQuestion.text sizeWithFont:[ThemeSettings fontUsedInQuestionCell] constrainedToSize:constSize lineBreakMode:UILineBreakModeWordWrap];
CGFloat height = (textSize.height)+60.0;
return height<45.0?45.0:height;
}else if([self answerGraphic: indexPath]){
UIImage *img = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[self answerGraphic: indexPath] ofType:nil]];
[self.answerImages replaceObjectAtIndex:indexPath.section withObject:img];
int size = (img.size.height*0.50)+10;
[img release];
return size;
}else {
int answerIndex = currentQuestion.graphic?indexPath.section-2:indexPath.section-1;
Answer *a=[currentQuestion.answers objectAtIndex:answerIndex];
CGSize constSize = { 300.0f, 20000.0f };
CGSize textSize = [a.text sizeWithFont:[UIFont systemFontOfSize:16] constrainedToSize:constSize lineBreakMode:UILineBreakModeWordWrap];
CGFloat height = (textSize.height+textSize.height/3.0 )+10.0;
return height<55.0?55.0:height;
}
}
请救救我