セルが選択されたときにビューコントローラーをプッシュする単純なグループ化されたテーブルビューがあります。ナビゲーション バーの左の項目は、テーブル ビューを「編集モード」にします。編集モードでは、必要に応じて各セルを移動および削除できます。私が望むのは、編集モードのときと通常モードのときに別のビューコントローラーをプッシュできるようにすることです。
これは、View Controller がプッシュされている場所です。
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
...stuff that doesnt matter...
[[self navigationController] pushViewController:detailViewController animated:YES];
}
BarButtonItems はここで宣言されています。
[[self navigationItem] setLeftBarButtonItem:[self editButtonItem]];
これは、すべての編集内容が宣言されている場所です。
- (void)tableView:(UITableView *)atableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
[atableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation: UITableViewRowAnimationFade];
}
}
- (void)tableView:(UITableView *)atableView
moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath
toIndexPath:(NSIndexPath *)destinationIndexPath
{
[[BNRItemStore sharedStore] moveItemAtIndex:[sourceIndexPath row]
toIndex:[destinationIndexPath row]];
}