UITableView のセルIndexで選択OK or NG を設定するメモ
テーブルの先頭セルだけ選択したくない、次のセル移行は選択させたい という時。
テーブルセルのデータ設定処理で、indexPath毎に処理を変える。(実際は、tag毎かな?)
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell; if (indexPath.row == 0) { [self createNoSeletionCell : cell]; } else { [self createSeletionCell : cell]; } return cell; }
テーブル選択させたくないセルには、選択色無しに。
- (void) createNoSeletionCell :(UITableViewCell *)cell { // 何か処理 : // 選択色無し設定 cell.selectionStyle = UITableViewCellSelectionStyleNone; }
テーブル選択OK のセルには、通常通りの設定。今回は、選択色をグレーに。
- (void) createSeletionCell :(UITableViewCell *)cell { UITableViewCell *cell = … : // 選択色をグレー設定 cell.selectionStyle = UITableViewCellSelectionStyleGray; }
なんてこと無いね。
もちろん テーブル選択した時の処理で、Index(or Tag) で判定して処理を実装!
こないだ 作った気がするのに、すーぐ忘れる…orz