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