2012-03-02 90 views
5

我的問題是這樣的:Reordering UITableView without reorder control,我用這些方法:重新排序的UITableView和隱藏重排序控制

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { 
    return YES; 
} 
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { 
    return UITableViewCellEditingStyleNone; 
} 
- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath { 
    return NO; 
} 
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { 
    return YES; 
} 
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath{ 

} 

而且

[self.tableView setEditing:YES]; 

...... 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 
    ItemTableViewCell *cell = (ItemTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ItemTableViewCell" owner:self options:nil]; 
     cell = [nib objectAtIndex:0]; 
    } 
    // ... 
    cell.showsReorderControl = NO; 
    return cell; 
} 

參考文獻:reordering control in UITableView

結果是的表可以重新排序,但重新排序控制從不隱藏。所以我想知道我是錯的,還是有人能幫助我?謝謝。

回答

5

檢查此網址:Reordering a UITableViewCell from any Touch point。這可能會對你有所幫助

+1

我可以建議嘗試[BVReorderTableView(https://github.com/bvogelzang/BVReorderTableView)?而不是黑客UITableView細胞子視圖它提供了一個更清潔的解決方案。 – bvogelzang 2013-03-23 17:55:29