我很困惑是否使用UIView addTarget:action:導致該視圖被保留。具體來說,我有一個UITableView自定義單元視圖,這是在視圖控制器上註冊一個事件。這些單元格視圖是自動發佈的。自動釋放和選擇器
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
UIView *cellView = [[UIView alloc] initWithFrame:viewRect];
[cellView addTarget:self action:@selector(dosSomething:) forControlEvents:UIControlEventTouchUpInside]; //is this not a good idea?
[cellView autorelease]; //will this get released?
}
謝謝。我來自ActionScript世界,事件監聽器可以阻止虛擬機中的垃圾收集,我在這裏有點偏執。 – akaru 2011-02-10 09:05:44