【发布时间】:2013-03-07 11:23:45
【问题描述】:
在我的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];
}
我的问题是,当我触摸左上角的“back”按钮时,创建的CustomViewController 永远不会释放(它消失但没有释放)。
如果我在 tableView:didSelectRowAtIndexPath: 中完成所有这些操作,它会按我的预期工作并得到适当的释放。
虽然我做的一切都是正确的,但不知道如何使它正确:(
编辑:是的,我正在使用ARC
【问题讨论】:
-
是的,忘了说谢谢
-
释放 customviewcontroller 的负担留给了编译器。所以它负责何时释放 customviewcontroller。
-
我确定我犯了一个错误,因为它永远不会被释放
ever -
你怎么知道它永远不会被释放?你是说 viewcontroller 中的后退按钮没有将你返回到 tableview 吗?
-
从这里查看我的答案stackoverflow.com/questions/19000356/…你不需要标签
标签: ios uitableview uibutton