UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectZero];
cell.accessoryView = switchView;
[switchView adTarget:selfaction:@selector(switchChanged:)forControlEvents:UIControlEventValueChanged];
[switchView release];
我在tableView:cellForRowAtIndexPath:中分配了切换视图。 我是否必须在dealloc中释放cell.accessoryView?我必须发布accessoryView吗?
这不比上面好吗?
cell.accessoryView = [[[UISwitch alloc] initWithFrame:CGRectZero]autorelease];
那么,我是否必须在dealloc中释放像这样的[cell.accessoryView release]或不? – user698200
不会。当单元格被释放时,它将自行释放。 – Akshay