iOSクラス[UITableView]の編集モードを
動的に切り替える方法です。
プログラム①
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { if( indexPath.row == 0 ) return UITableViewCellEditingStyleNone; else return UITableViewCellEditingStyleDelete; }
プログラム②
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { if( indexPath.section == 0 ) return NO; else return YES; }
解説
プログラム①は表示するEditStyleを定義します。
戻り値は列挙型[UITableViewCellEditingStyle]です。
プログラム②は表示するかしないを定義します。
戻り値はbool型で【YES】の場合は編集モードになり、
【NO】なら編集モードへの移行をさせません。
検索すると関数[shouldIndentWhileEditingRowAtIndexPath]が
上位に引っかかったので間違えないようにメモしました。