ARC を使用した非常に単純なテスト アプリがあります。ビュー コントローラーの 1 つに UITableView が含まれています。行アニメーション(insertRowsAtIndexPaths
またはdeleteRowsAtIndexPaths
)UITableView(およびすべてのセル)を作成した後、割り当てが解除されることはありません。を使用する reloadData
と、正常に動作します。iOS 6 では問題ありません。iOS 7.0 のみです。このメモリリークを修正する方法はありますか?
-(void)expand {
expanded = !expanded;
NSArray* paths = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:0 inSection:0], [NSIndexPath indexPathForRow:1 inSection:0],nil];
if (expanded) {
//[table_view reloadData];
[table_view insertRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationMiddle];
} else {
//[table_view reloadData];
[table_view deleteRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationMiddle];
}
}
-(int)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return expanded ? 2 : 0;
}
table_view は、クラス TableView (UITableView のサブクラス) の一種です。
@implementation TableView
static int totalTableView;
- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
{
if (self = [super initWithFrame:frame style:style]) {
totalTableView++;
NSLog(@"init tableView (%d)", totalTableView);
}
return self;
}
-(void)dealloc {
totalTableView--;
NSLog(@"dealloc tableView (%d)", totalTableView);
}
@end