0

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

4

1 回答 1

1

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

inside - (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];
于 2012-08-24T07:00:12.187 回答