【发布时间】:2012-07-10 14:10:29
【问题描述】:
I have a simple grouped table view that when a cell is selected it pushes a 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]];
}
【问题讨论】:
标签: objective-c ios xcode cocoa-touch editing