从 StoryBoard 加载的自定义 UITableViewCell 未被释放
Custom UITableViewCell loaded from StoryBoard not getting dealloc'ed
这是我的代码:
__weak CurrentViewController *weakSelf = self;
if (indexPath.row == 0) //Name Cell
{
static NSString *CellIdentifier = @"NameCell";
NameCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
__weak NameCell *weakCell = cell;
cell.NameDidChangeBlock = ^(){
weakSelf.zoneName = weakCell.NameTextField.text;
};
return cell;
}
else if (indexPath.row == 1) //Number Cell
{
static NSString *CellIdentifier = @"NumberCell";
NumberCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.someBlock = ^(){
[weakSelf.navigationController popViewControllerAnimated:YES];
};
return cell;
}
"NameCell" 和 "NumberCell" 都没有调用 dealloc 方法。
我在 CurrentViewController 的情节提要中将这两个自定义单元设计并设置为顶层 objects。
正在调用 CurrentViewController 的 dealloc,但未调用自定义单元格的 dealloc。
我在 Instruments 中看到每次创建 CurrentViewController 实例时自定义单元格的 retainCount 都会增加。
这是我的 headers 个自定义单元格:
//NameCell.h:
@property(nonatomic, weak)IBOutlet UITextField *NameTextField;
@property (nonatomic, copy)NameDidChange NameDidChangeBlock;
//NumberCell.h
@property(nonatomic, weak)Manager *manager;
@property(nonatomic, weak)IBOutlet AKPickerView *pickerView;
@property(nonatomic, strong)NSArray *numbersArray;
@property(nonatomic)int selectedZoneNumber;
@property (weak, nonatomic) IBOutlet UIView *selectionBoxView;
@property (nonatomic, copy)some someBlock;
如有任何帮助,我们将不胜感激。
谢谢!
编辑:
在 CurrentViewController 被解除分配后,我的 tableView 本身没有被解除分配。
尝试通过 UITableView 类别登录。
仍然,猜测,为什么我的 tableView 不会在我的 viewController 已经发布时发布。似乎太奇怪了。
罪魁祸首是这个人:ShowKit
我们将 ShowKit 集成到我们的应用程序中以提供远程支持。
从我们的应用程序中删除他们的 SDK 确实解决了上述 dealloc 问题(不仅是上述问题,而且问题比我们想象的要多)。
我认为 ShowKit SDK 确实获取了我们应用程序视图的副本,但没有 return 将其返回,可能是复制视图的保留计数根本没有变为 0。
或
可能是 SDK 控制了我的应用程序的 UIWindow 并且他们在不需要时不会释放它。
这纯粹是我的猜测,但不确定。他们必须回答。
我希望有人觉得这有帮助。
这是我的代码:
__weak CurrentViewController *weakSelf = self;
if (indexPath.row == 0) //Name Cell
{
static NSString *CellIdentifier = @"NameCell";
NameCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
__weak NameCell *weakCell = cell;
cell.NameDidChangeBlock = ^(){
weakSelf.zoneName = weakCell.NameTextField.text;
};
return cell;
}
else if (indexPath.row == 1) //Number Cell
{
static NSString *CellIdentifier = @"NumberCell";
NumberCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.someBlock = ^(){
[weakSelf.navigationController popViewControllerAnimated:YES];
};
return cell;
}
"NameCell" 和 "NumberCell" 都没有调用 dealloc 方法。 我在 CurrentViewController 的情节提要中将这两个自定义单元设计并设置为顶层 objects。
正在调用 CurrentViewController 的 dealloc,但未调用自定义单元格的 dealloc。 我在 Instruments 中看到每次创建 CurrentViewController 实例时自定义单元格的 retainCount 都会增加。
这是我的 headers 个自定义单元格:
//NameCell.h:
@property(nonatomic, weak)IBOutlet UITextField *NameTextField;
@property (nonatomic, copy)NameDidChange NameDidChangeBlock;
//NumberCell.h
@property(nonatomic, weak)Manager *manager;
@property(nonatomic, weak)IBOutlet AKPickerView *pickerView;
@property(nonatomic, strong)NSArray *numbersArray;
@property(nonatomic)int selectedZoneNumber;
@property (weak, nonatomic) IBOutlet UIView *selectionBoxView;
@property (nonatomic, copy)some someBlock;
如有任何帮助,我们将不胜感激。 谢谢!
编辑: 在 CurrentViewController 被解除分配后,我的 tableView 本身没有被解除分配。 尝试通过 UITableView 类别登录。 仍然,猜测,为什么我的 tableView 不会在我的 viewController 已经发布时发布。似乎太奇怪了。
罪魁祸首是这个人:ShowKit
我们将 ShowKit 集成到我们的应用程序中以提供远程支持。
从我们的应用程序中删除他们的 SDK 确实解决了上述 dealloc 问题(不仅是上述问题,而且问题比我们想象的要多)。
我认为 ShowKit SDK 确实获取了我们应用程序视图的副本,但没有 return 将其返回,可能是复制视图的保留计数根本没有变为 0。
或
可能是 SDK 控制了我的应用程序的 UIWindow 并且他们在不需要时不会释放它。
这纯粹是我的猜测,但不确定。他们必须回答。
我希望有人觉得这有帮助。