在我的UITableViewCell
子類中有一個UIButton
裏面應該推新制作的UIViewController
。UITableViewCell中的UIButton沒有釋放它創建的UIViewController
我做了兩種方法是這樣的:
- (void)configureCellWithObject:(Object *)object {
self.object = object;
[self.button1 addTarget:self action:@selector(initCustomController) forControlEvents:UIControlEventTouchUpInside];
// self.button1 is a UIButton
}
- (void)initCustomController {
CustomViewController *cvc = [[CustomViewController alloc]initWithObject:self.object];
// self.nc is the navigation controller of the UITableView presenting the cell
[self.nc pushViewController:cvc animated:YES];
}
而我的問題是創建CustomViewController
永遠不會釋放,當我輕觸左上角的「back
」按鈕(即消失,但沒有被釋放)。
如果我在tableView:didSelectRowAtIndexPath:
中做了所有的工作,它可以像我預期的那樣工作並獲得正確的發佈。
我,雖然我做的一切都是正確的,但無法弄清楚如何作出正確的:(
編輯:是的,我用ARC
你使用弧? – lakesh 2013-03-07 11:26:36
是的忘了提到它謝謝 – ItsASecret 2013-03-07 11:26:54
釋放customviewcontroller的負擔留給編譯器。所以它會照顧何時釋放customviewcontroller。 – lakesh 2013-03-07 11:29:09