0

我已经在 AppDelegate 中实现了 createCellForTableview: 方法,该方法创建单元格,将适当的 UIButton 作为附件视图添加到单元格并将单元格返回给控制器。在我的 viewController 中,我正在创建附件视图的实例并将目标添加到按钮作为休闲:

 button = (UIButton *)cell.accessoryView;
 [button setTitle:@"access" forState:UIControlStateNormal];
 [button setTitle:@"access" forState:UIControlEventTouchUpInside];
 [button addTarget:self action:@selector(accessButtonTapped:event:)  forControlEvents:UIControlEventTouchUpInside]; 

我的问题是,没有调用按钮操作。请帮我解决这个问题。

提前致谢

4

3 回答 3

0

将 @selector 更改为 accessButtonTapped:

于 2012-06-28T11:59:36.150 回答
0

如果是附属按钮,则需要调用此方法:

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
于 2012-06-28T12:42:42.327 回答
0

为什么你在选择器方法中传递偶数..试试这个..

button = (UIButton *)cell.accessoryView;
[button setTitle:@"access" forState:UIControlStateNormal];
[button setTitle:@"access" forState:UIControlEventTouchUpInside];
[button addTarget:self action:@selector(accessButtonTapped:)forControlEvents:UIControlEventTouchUpInside];

这可能会帮助你

于 2012-06-28T12:02:30.343 回答