UITableViewCell *theCell;
theCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
UIImage *theImage = [UIImageView imageNamed:@"image.png"];
UIImageView *theView = [[UIImageView alloc] initWithImage:theImage];
theCell.accessoryView = theView;
[theView release];
のように使う。UIImageView imageNamed:はあまり使うべきではないが、ここでは同じイメージを使い回すことを前提にして使っている。
サンプルではNSButtonをアクセサリービューとしてつけているので、そのアクションの設定の仕方も参考になる。
マウスクリック位置から選択されたテーブルの行を判定する方法:
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint: currentTouchPosition];
テーブル行が選択されたときの行反転の色を変える方法:
cell.selectionStyle = UITableViewCellSelectionStyleGray;
選択種類には以下がある。
UITableViewCellSelectionStyleNone,
UITableViewCellSelectionStyleBlue,
UITableViewCellSelectionStyleGray
選択をしたときの表示の変更をアニメーションにすることもできる。
アクセサリービューを独自ビューにするつ以外に既定のもの(チェックマーク、詳細ありボタンにするなどができます。
UITableViewCellAccessoryNone,
UITableViewCellAccessoryDisclosureIndicator,
UITableViewCellAccessoryDetailDisclosureButton,
UITableViewCellAccessoryCheckmark

