9
セクションの最初のセルにreloadRowsAtIndexPathsを呼び出すと、前のセクションが空で空のセルが空である場合、再ロードされたセルがどこにあるのか不思議なアニメーショングリッチが発生します( "UITableViewRowAnimationNone"私は一例に可能な限り簡素化しようとした...ダウン上記のセクションからUITableView reloadRowsAtIndexPathsグラフィカルグリッチ
をスライド:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0)
return 1;
else if (section == 1)
return 0;
else if (section == 2)
return 3;
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
cell.textLabel.text = @"Text";
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSArray *editedCell = [[NSArray alloc] initWithObjects:indexPath, nil];
//[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:editedCell withRowAnimation:UITableViewRowAnimationNone];
//[self.tableView endUpdates];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return @"Section";
}
実はあなたは最後の方法をコメントアウトすることができますが、それは問題のより良い理解を提供します。
、とにかく、奇妙な行動からは、次のとおりです。また、明確なコードを作成し、コードの重複を避けるためには、別の方法(ので、我々は別の場所からそれを呼び出すことができるようになります)に、セルのセットアップを移動することができますreloadRowsAtIndexはバグを返しますか、それとも間違った方法で使用していましたか? – Fr4ncis
@ Fr4ncis、わかりません。セルテーブルビューをリロードするには、ビュー階層から追加/削除したり、サブビューやその他のものを再構築したりする必要があります。これらの変換が内部的にどのように実装されるかによって異なります。 – Vladimir
ありがとうございます。 – jalopezsuarez