Iphone UITableCell中的UIButton-选择器操作未触发

Iphone UITableCell中的UIButton-选择器操作未触发,iphone,objective-c,uibutton,Iphone,Objective C,Uibutton,我有一个自定义UITableCell类和一个用于加载UITableCell的ViewController类 在控制器中: - (void)viewDidLoad { CustomeCell *cell = (CustomeCell *)self.view; } Custome单元格是从.xib加载的,因此我尝试通过以下方式将UIbutton添加到单元格: UIButton *customButton = [UIButton buttonWithType:UIButtonTypeCustom];

我有一个自定义UITableCell类和一个用于加载UITableCell的ViewController类

在控制器中:

- (void)viewDidLoad
{
CustomeCell *cell = (CustomeCell *)self.view;
}
Custome单元格是从.xib加载的,因此我尝试通过以下方式将UIbutton添加到单元格:

UIButton *customButton = [UIButton buttonWithType:UIButtonTypeCustom];
customButton.frame = CGRectMake(270, 3, 40, 40);
customButton.backgroundColor = [UIColor blueColor];
[customButton setTitle:@"X";
//customButton.tag = 99999;
[customButton addTarget:self action:@selector(delete:) forControlEvents: UIControlEventTouchUpInside];
[cell.contentView addSubview:customButton];
在同一控制器类中,我有:

- (void)delete:(UIButton *)sender
{
   NSLog(@"doing something");
}
但单击按钮后,我收到了以下错误消息: [CellViewController性能选择器:withObject:withObject:]:消息已发送到解除分配的实例0x1197a280 [切换到进程4598线程0x15203] 当前语言:自动;当前目标-c


我做错了什么?如何消除此错误消息?

按下按钮时,视图控制器已释放并解除分配。这将有助于提供一个上下文-当按钮与视图控制器相关时,它会做什么。问题,在viewDidLoad方法中,为什么要将customeCell设置为视图控制器的视图?您能在CellForRowatineXpath方法中显示其余的代码吗?@JacobJennings该按钮被假定为删除表中的行,但尚未实现。它是在控制器的viewDidLoad中创建的。我通过删除该版本修复了该问题,谢谢