我不知道为什么会这样,但我得到了这个错误:
-[__NSArrayM 部分]:无法识别的选择器发送到实例 0x7e53b70 2012-01-07 15:35:44.108 Timely1[51661:15203] *由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[__NSArrayM 部分]:无法识别的选择器发送到实例 0x7e53b70'
什么时候handleTouch
激活。这是我添加图像和点击手势的代码。
[cell.imageView setUserInteractionEnabled:YES];
[cell.imageView setImage:[UIImage imageNamed:@"checkbox.PNG"]];
UITapGestureRecognizer *tapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTouch:)];
tapped.numberOfTapsRequired = 1;
[cell.imageView addGestureRecognizer:tapped];
[tapped release];
然后是我处理触摸的代码:
-(void)handleTouch:(UITapGestureRecognizer *)gesture
{
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[array count] inSection:1];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
[cell.imageView setImage:[UIImage imageNamed:@"checkbox_checked.PNG"]];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:array] withRowAnimation:UITableViewRowAnimationFade];
}
更新:如果我想取消选中它(比如切换它),有人知道该怎么做吗?