1

これを解決する方法についてのアイデアが得られない...。

Ok。これは、UITableViewCell3つの異なる子ビューを使用した私の習慣です。さまざまな色で見ることができます。

ここに画像の説明を入力してください

ここで、2番目の子ビューの高さは動的であり、実行時に計算されます。の高さを設定するために使用 しています。-heightForRowAtIndexPathUITableViewCell

私が試したこと:

子ビューのアウトレットを設定してから、 -heightForRowAtIndexPathこのコードを使用しました...

middleView.frame = CGRectMake(0, 60.0, 750.0, size);
footerView.frame = CGRectMake(0, size + 60.0, 750.0, 50.0);

ここで、size=動的に計算されたミドルビューの高さ。

アップデート :

私もこのようなサイズの静的な値で試しました...

 middleView.frame = CGRectMake(0, 60.0, 750.0, 350.0);
 footerView.frame = CGRectMake(0, 350.0 + 60.0, 750.0, 50.0);

しかし、運はまったくありません...。

サイズはこれによって計算されます:size = (elements * 30) + 50;

ここで、elements=配列内の要素の数。

問題 :

スクリーンショットを見てください。

助言がありますか ?

4

2 に答える 2

1

heightForRowAtIndexPathではなく、次のメソッドでミドルビューとフッタービューのフレームを設定します。

上記のindraMohanによって与えられた他の方法を維持します。

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath       *)indexPath
{   
NSString * cellIdentifier = @"TableViewCellIdentifier"  ;
InAppTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

cell.delegate = self;
float size = [self heightForMiddleViewAtIndexPath: indexPath]
cell.middleView.frame = CGRectMake(0, 60.0, 750.0, size);
cell.footerView.frame = CGRectMake(0, size + 60.0, 750.0, 50.0);
return cell;

}

于 2013-03-06T12:38:26.827 に答える
0

この問題を解決するには、2つのことを行う必要があります

  1. 適切なautoresizingMaskをすべての子ビューに設定します

        headerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
    middleView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    footerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; 

  2. UITableViewDelegateメソッドから適切な高さを返します

    
    
    • (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return [self heightForMiddleViewAtIndexPath: indexPath] + footerViewHeight + headerViewheight; }

    • (CGFloat)heightForMiddleViewAtIndexPath:(NSIndexPath *)indexPath { \ do some height calculation; }

于 2013-03-06T12:08:27.733 に答える