【发布时间】:2013-12-29 21:13:40
【问题描述】:
我有自定义 UITableViewCell 和此代码来创建配件
UIImage *indicatorImage = [UIImage imageNamed:@"Map.png"];
UIButton *button = [[UIButton alloc] init];
[button setImage:indicatorImage forState:UIControlStateNormal];
[button setFrame:CGRectMake(0, 0, 64, 64)];
cell.accessoryView = button;
我有这两种方法:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//[self performSegueWithIdentifier:@"goToDetail" sender:self];
NSLog(@"row");
}
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{
//[self performSegueWithIdentifier:@"goToMap" sender:self];
NSLog(@"accessory");
}
我想捕获两个不同的事件:一个用于行,一个用于附件,使用我上面提到的两种方法,我只能获取行的事件。如何获得配件?
请帮忙
【问题讨论】:
-
它应该类似于为按钮指定目标的方式。您只需将目标添加到按钮即可使其工作。
-
我找到了这个解决方案...
-
我将此行添加到我的按钮:[button addTarget:self action:@selector(methodTouchDown:) forControlEvents:UIControlEventTouchDown];
-
然后我使用这个方法:-(void)methodTouchDown:(id)sender
标签: ios uitableview