我不知道为什么发生这种情况,但我得到这个错误:在单元格中处理UIImageView触摸时出错?
-[__NSArrayM section]: unrecognized selector sent to instance 0x7e53b70 2012-01-07 15:35:44.108 Timely1[51661:15203] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM section]: unrecognized selector sent to instance 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];
}
UPDATE:怎么样,如果我想取消它(如翻转它)没有任何人知道该怎么做?
在我看来,你以前遇到的问题在于 - NSIndexPath * indexPath = [NSIndexPath indexPathForRow:[array count] inSection:1];相反,你需要使用NSIndexPath * indexPath = [NSIndexPath indexPathForRow:[array count] -1 inSection:1]; – rishi 2012-01-07 16:59:43
是的,但是你知道如何修复'[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:array] withRowAnimation:UITableViewRowAnimationFade];'因为我知道那是问题所在,但是如果我想再次加载一个单元格,不再使用该行。 – Souljacker 2012-01-07 17:15:41
你是否在数组中传递NSIndexPath的对象? – rishi 2012-01-07 17:17:35