私はcellForRowAtIndexPathの各セルの高さを計算するテーブルビューを持っており、heightForRowAtIndexPathはその結果を使用します。reloaddataテーブルビューの位置が正しくないようにする
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"PhotoCell";
UITableViewCell *sectionHeaderView = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (sectionHeaderView == nil)
{
sectionHeaderView = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
//setting up the cell
and also calculate the total height required for this cell and save to _eachcellheight
}
そのセルの部分です。
- (void)viewWillAppear:(BOOL)animated {
CGPoint offset = tableView.contentOffset;
[tableView reloadData];
[tableView setContentOffset:offset];
}
ビューでは、テーブルのデータをリロードする必要があります。オプション1初めにテーブル表示を使用するといいと思いますが、テーブルのオフセットreloaddata後に奇妙に行くとスクロールがまた奇妙行く場合
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return _eachcellheight; //option 1
return 200; //option 2
}
は今問題があります。
しかし、オプション2を使用すると、それぞれ200.fを返します。リロードデータは正常に動作し、以前と同じ位置にとどまることができます。 テーブルのセルの高さが異なる必要があります。
どうすれば解決できますか? 私はこの問題を3日間解決しています。
しかし、各セルの高さは、cellForRowAtIndexPathのすべてのデータのベースを計算する必要があります。私は移動することはできません。使用可能な配列と同じ高さにすることはできますか?それは可能でしょうか? –