UITableViewCell を取得して、ハイライト時にaccessoryViewを変更しようとしています。そのため、ハイライトするとアクセサリが暗くなります。これまでのところ、1 つの例外を除いて、うまく機能させることができました。セルが押されるとセルが強調表示されますが、そのプレスが動かされて強調表示がキャンセルされると、accessoryView は強調表示された画像を保持します。
ハイライトがキャンセルされたかどうかを検出して、accessoryView を元の状態に戻す方法はありますか? これを実現するには、UITableViewCell のサブクラスを作成する必要がありますか? どんな助けでも大歓迎です。ありがとう!
通常の状態:
強調表示された状態
タッチを押して動かした後(避けたいこと):
- (void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
UIImageView *accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"accessoryDark.png"]];
cell.accessoryView = accessoryView;
}
- (void)tableView:(UITableView *)tableView didUnhighlightRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
UIImageView *accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"accessory.png"]];
cell.accessoryView = accessoryView;
}