按钮事件未在uitableviewCell中被触发

时间:2012-08-24 06:53:24

标签: objective-c xcode

我在我的笔尖中添加了一个tableviewCell,我在一个单元格中添加了一个UIButton。问题是按钮的IBAction没有被触发。我可以点击按钮你们可以帮帮忙。会非常好

1 个答案:

答案 0 :(得分:1)

另一种方法...创建一个uibutton并将其添加到您需要它的单元格

里面 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 使用开关检查表格行

switch (indexPath.row)

如果案例匹配则使用此

UIButton *yourButton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[yourButton addTarget:self action:@selector(your_method_to_handle_button_clicked) forControlEvents:UIControlEventTouchUpInside];
yourButton.frame=CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>);

[cell addSubview:yourButton];
相关问题