I have an application that uses tableview, as well as UIButton, which I add as a slave for each user cell, for example:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; checkButton = [[UIButton buttonWithType:UIButtonTypeCustom] initWithFrame:CGRectMake(2.0, 2.0, 40.0, 40.0)]; [cell.contentView addSubview:checkButton];
I thought that everything was in order until I started using the Tools to make sure that I did not have memory leaks, but I found that adding UIButton as a cell spy somehow caused a leak inside UIKit.
In particular, I get a memory leak for each row of cells (every time the button is added as a preview), and the leaked object is "CALayer", and the responsible frame is "[UIView _createLayerWithFrame:]".
Am I doing something wrong here?
source share