2012-06-07 61 views
1

从UITableViewCell的showsReorderControl文档:不能使表重新排序工作

For the reordering control to appear, you must not only set this property but implement the UITableViewDataSource method tableView:moveRowAtIndexPath:toIndexPath:. In addition, if the data source implements tableView:canMoveRowAtIndexPath: to return NO, the reordering control does not appear in that designated row. 

我已经得到了无论是在我的tableviewController:

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { 
    return YES; 
} 

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { 
    NSLog(@"move from:%d to:%d", fromIndexPath.row, toIndexPath.row); 
    //just for test 
} 

我的细胞特性,包括重新排序控件:

enter image description here

然而,我看不到重新排序合作Ntrol,我错过了什么?

回答

2

你有没有把你的UITableView进入编辑模式通过

[tableView setEditing:YES animated:YES]; 

顺便提一下,您发布的第一个方法是不必要的,因为这是默认行为。

+0

打我一秒!伟大的思想,我想;-) – Dima

2

我认为你需要真正进入表格的编辑模式。当你的视图出现的时候,你可以在代码中尝试它,或者创建一个按钮来完成它。

[tableView setEditing:YES animated:YES];