Я заметил, что один из моих пользовательских UITableViewCell протекает. Он не освобождается при выполнении редактирования, удаляет нижнюю ячейку и коснитесь «Сохранить». Это моя верхняя ячейка в таблице (я называю ее добавочной ячейкой). Когда мой просмотр таблицы находится в режиме редактирования, добавляется ячейка со всеми остальными ячейками, отображаемыми снизу с включенным режимом удаления. Теперь, после выполнения операции удаления и сохранения данных, Add Cell все еще держится, даже если вызывается dealloc в моем представлении таблицы.UITableViewCell Утечка при удалении и сохранении ячейки
Я прилагаю мой код и скриншот инструмент (я удалил первую строку (Malloc вызова) на скриншоте. Для меня, это, кажется, что-то неправильно в IOS внутренней обработки. Пожалуйста посоветуйте.
- (UITableViewCell *)tableView:(UITableView *)iTableView cellForRowAtIndexPath:(NSIndexPath *)iIndexPath {
MyTableViewCell *aCell = nil;
NSString *aCellType;
if (iIndexPath.row == 0 && self.inEditMode) {
aCellType = kMyAddCell;
aCell = (MyAddCell *)[iTableView dequeueReusableCellWithIdentifier:aCellType];
if (!aCell) {
aCell = [[MyAddCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:aCellType];
}
aCell.isGroupedView = YES;
aCell.delegate = self;
aCell.textLabel.text = @“Add More";
self.tableView.allowsSelectionDuringEditing = YES;
} else {
aCellType = kMyDefaultCell;
aCell = (MyTableViewCell *)[iTableView dequeueReusableCellWithIdentifier:aCellType];
if (!aCell) {
aCell = [[MyTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:aCellType];
}
NSInteger anIndex = iIndexPath.row;
if (self.inEditMode) {
anIndex = anIndex - 1;
}
aCell.textLabel.text = @“Name";
aCell.selectionStyle = UITableViewCellSelectionStyleNone;
}
return aCell;
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView editingStyleForRowAtIndexPath:(NSIndexPath *)iIndexPath {
return (iIndexPath.row == 0 && self.inEditMode) ? UITableViewCellEditingStyleNone : UITableViewCellEditingStyleDelete;
}
- (BOOL)tableView:(UITableView *)iTableView canEditRowAtIndexPath:(NSIndexPath *)iIndexPath {
return YES;
}
- (void)tableView:(UITableView *)iTableView commitEditingStyle:(UITableViewCellEditingStyle)iEditingStyle forRowAtIndexPath:(NSIndexPath *)iIndexPath {
if (iEditingStyle == UITableViewCellEditingStyleDelete) {
[self setSaveModeNavigationBar];
[self.tableView beginUpdates];
[self.enabledUsers removeObjectAtIndex:(self.inEditMode) ? iIndexPath.row - 1 : iIndexPath.row];
[self.tableView deleteRowsAtIndexPaths:@[iIndexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView endUpdates];
}
}
- (void)setEditing:(BOOL)iEditing animated:(BOOL)iAnimated {
[super setEditing:iEditing animated:iAnimated];
[self.navigationItem setHidesBackButton:YES animated:NO];
self.headerViewLabel.text = @“Edit Me";
UIBarButtonItem *aDoneButton = [[UIBarButtonItem alloc] initWithTitle:@“Done"
style:UIBarButtonItemStylePlain
target:self
action:@selector(cancelEditing)];
[self.navigationItem setRightBarButtonItem:aDoneButton];
[self.navigationItem setLeftBarButtonItem:nil animated:YES];
self.inEditMode = YES;
[self.tableView reloadData];
}
код, который вызывается, когда я нажмите на кнопку Сохранить:
self.requestHandler = [[MyRequestHandler alloc] initWithEndPoint:myEndPoint body:aPostBody successHandler:^(NSDictionary *iResponse) {
[aBlockSelf addNoDataOverlay];
} andErrorHandler:^(NSString *iMessage, NSString *iKey, NSInteger iErrorCode, BOOL iIsNetworkError) {
[aBlockSelf addNoDataOverlay];
}];
[self.requestHandler executeRequest];
Инструмент Выделение Stack: