iPhoneアプリのユーザインタフェースの作りこみ(おまけ)
下記、説明を忘れていました。
editingStyleForRowAtIndexPathメソッドで、戻り値をeditingStyleForRowAtIndexPathをセットすると、編集モードで自動で表示されるアイコンが表示されなくなります。
- (UITableViewCellEditingStyle)tableView:(UITableView*)tableView editingStyleForRowAtIndexPath:(NSIndexPath*)indexPath { return UITableViewCellEditingStyleNone; }
また、shouldIndentWhileEditingRowAtIndexPathで、戻り値をNOにセットすると編集モードで自動的にインデント(右にスライド)されなくなります。今回は自分でずらすコードを書いていますので、インデントしない設定にしています。
- (BOOL)tableView:(UITableView*)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath*)indexPath { return NO; }
Sample.zipでは、didSelectRowAtIndexPathメソッド内で、deselectRowAtIndexPath:indexPathを呼んでいます。これを入れないと、デフォルトでは選択したセルが青く反転した状態になってしまうからです。Appleの審査でもリジェクト理由になるので、入れておきました。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // セルの選択色解除 [tableView deselectRowAtIndexPath:indexPath animated:NO]; // 編集モード判定 if (self.editing == NO) { ・ ・ ・ }
セルの選択解除の代わりに、セルのselectionStyleプロパティにUITableViewCellSelectionStyleNoneを入れるのもありです。選択時の反転を無くすことができます。こちらの方が標準のメールに近いですね。
cell = [tableView dequeueReusableCellWithIdentifier:@"custum"]; if (cell == nil) { cell = [[[UITableViewCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"custum"] autorelease]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.selectionStyle = UITableViewCellSelectionStyleNone; }