削除するにはセルを取得する必要がありますindexPath
が、新しいファイルを確認するためにアプリが 2 秒後に自動リロードindexpath
されるため、変更されたため、正しく取得できません。今、セルを取得したいのですが、セルを保存する方法がわかりません。これは私のコードです:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//[_tableView clearsContextBeforeDrawing];
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.tag = indexPath.row;
if([FileNameArray count] != 0){
CGRect frame = CGRectMake(10, 05, 100, 20);//(20, 0, 80, 40);
UILabel *lbl1 = [[UILabel alloc]initWithFrame:frame];
[lbl1 setFont:[UIFont fontWithName:@"Helvetica" size:15.0]];
[lbl1 setTextColor:[UIColor blackColor]];
[lbl1 setTextAlignment:UITextAlignmentLeft];
lbl1.text = [FileNameArray objectAtIndex:indexPath.row];
[cell addSubview:lbl1];
[lbl1 release];
}
return cell;
}
removeCell
関数:
-(void) removeCell:(NSIndexPath *)indexPath
{
[_tableView beginUpdates];
[_tableView deleteRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade];
// [_tableView reloadData];
[_tableView endUpdates];
}
提案はありますか?