2012-03-02 32 views
5

Câu hỏi của tôi là như thế này: Reordering UITableView without reorder control, tôi sử dụng các phương pháp:Sắp xếp lại UITableView và ẩn sắp xếp lại kiểm soát

- (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; 
} 

Tài liệu tham khảo: reordering control in UITableView

Kết quả là sự bảng có thể được sắp xếp lại, nhưng điều khiển sắp xếp lại không bao giờ ẩn. Vì vậy, tôi tự hỏi nếu tôi sai, hoặc nếu ai cũng có thể giúp tôi? Cảm ơn bạn.

Trả lời

5

Kiểm tra URL này: Reordering a UITableViewCell from any Touch point .Đây có thể là hữu ích cho bạn

+1

Tôi có thể đề nghị cố gắng [BVReorderTableView] (https://github.com/bvogelzang/BVReorderTableView)? Thay vì hack các subviews UITableView, nó cung cấp một giải pháp sạch hơn một chút. – bvogelzang

Các vấn đề liên quan