UITutCell中的UIButton - 未触发action @selector

时间:2011-11-11 21:31:45

标签: iphone objective-c uibutton

我有一个Custom UITableCell类和一个用于加载UITableCell的ViewController类。

在控制器中:

- (void)viewDidLoad
{
CustomeCell *cell = (CustomeCell *)self.view;
}

客户端单元从.xib加载,因此我尝试通过以下方式向单元格添加UI按钮:

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 performSelector:withObject:withObject:]:消息发送到解除分配的实例0x1197a280 [切换到进程4598线程0x15203] 当前语言:auto;目前的目标-c

我做错了什么?如何摆脱这条错误信息?

0 个答案:

没有答案