У меня есть таблица с пользовательской ячейкой.Эти клетки имеют разную высоту, и я знаю, как рассчитать высоту.Проблема в том, что метод heightForRowAtIndexPath вызывается перед методом cellForRowAtIndexPath , поэтому я не могу передать CGFloat возврата.
Есть ли способ вызвать этот метод после?
Большое спасибо
EDIT
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
CustomCellFavorites *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[CustomCellFavorites alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.topSuperiore = self;
}
//textviews
NSString *string01 = ((Traduzioni *)[self.arrayTraduzioni objectAtIndex:indexPath.row]).testoOriginale;
NSString *string02 = ((Traduzioni *)[self.arrayTraduzioni objectAtIndex:indexPath.row]).testoTradotto;
[cell loadItem:string01 :string02];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
CustomCellFavorites *cell = (CustomCellFavorites*)[self tableView:tableView cellForRowAtIndexPath:indexPath];
return cell.heightCell;
}
пользовательский метод ячейки
-(void)loadItem:(NSString *)text01:(NSString *)text02 {
textView01.text = text01;
CGRect rect = textView01.frame;
rect.size.height = textView01.contentSize.height;
textView01.frame = rect;
[tv01Bg setFrame:CGRectMake(32, 0, 288, (textView01.contentSize.height)+20)];
textView02.text = text02;
CGRect rect2 = textView02.frame;
rect2.size.height = textView02.contentSize.height;
textView02.frame = rect2;
[tv02Bg setFrame:CGRectMake(0, (textView01.contentSize.height)+20, 320, (textView02.contentSize.height)+20)];
heightCell = (rect2.origin.y)+(rect2.size.height)+15.5;
}