我试图添加按钮,进入我的表格单元格象下面这样:添加按钮到的UITableViewCell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
....
UIButton* buttonCheckbox = [UIButton buttonWithType:UIButtonTypeCustom];
buttonCheckbox.frame = CGRectMake(0, 177, 56, 26);
buttonCheckbox.backgroundColor = [UIColor redColor];
[buttonCheckbox addTarget:self action:@selector(actionFirst1) forControlEvents:UIControlEventTouchUpInside];
[buttonCheckbox setTitle:@"MyTitle" forState:UIControlStateNormal];
[cell addSubview:buttonCheckbox];
但actionFirst1事件不被解雇。如果我添加按钮[self.view addSubview:buttonCheckbox]
而不是[cell addSubview:buttonCheckbox]
它工作正常。为什么?
感谢...
通常你的操作方法将有一个sender参数(ID),在这种情况下,选择将是'@selector(actionFirst1:)' – progrmr