1

なぜこれが起こっているのかわかりませんが、次のエラーが表示されます。

-[__NSArrayM セクション]: 認識されないセレクターがインスタンス 0x7e53b70 2012-01-07 15:35:44.108 Timely1[51661:15203] に送信れましたインスタンス 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];
}

更新:チェックを外したい場合はどうですか(トグルするなど)、その方法を知っている人はいますか?

4

2 に答える 2

2

あなたのhandleTouchメソッドで私はあなたが使うことができると思います:

UIImageView *cellImageView=(UIImageView *)gesture.view;
于 2012-01-07T15:05:25.973 に答える
0

私はチェックボックスとして aUIButtonを使用し、 my をサブクラス化することUITableViewCellにしました。特にトグルビットを使用すると、より簡単で論理的に見えます。

于 2012-01-08T15:13:33.947 に答える