2009-09-01 37 views
18

Tôi đang phát triển trò chơi mà tôi đang sử dụng UITableView có ô tùy chỉnh (UItableViewCell phân lớp).kiểm soát sắp xếp lại trong UITableView

Trong chế độ chỉnh sửa: Chỉ kiểm soát sắp xếp lại UITableView mới hiển thị.

Hiện tại tôi đang xóa và kiểm soát sắp xếp lại.

Làm cách nào để chỉ kiểm soát sắp xếp lại trong khi chỉnh sửa?

Trả lời

1
tableView.showsReorderControl = YES; // to show reordering control 

Để dissmiss kiểm soát xóa, trong UITableViewDelegate bạn thêm

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    return UITableViewCellEditingStyleNone; 
} 
4

thanks a lot oxigen nó làm việc .... tôi đã viết những dòng này trong

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView1 dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if (!cell) { 
     cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 
    } 

    cell.showsReorderControl = YES; // to show reordering control 

    return cell; 
} 

nhưng tôi dint viết phương thức bạn đã cung cấp

Cảm ơn một tấn

61

Tôi biết câu trả lời này có thể là muộn, nhưng tôi đặt nó chỉ dành cho những người vẫn cần nó. Chỉ cần thực hiện các phương pháp sau:

- (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{ 

} 
+0

vẫn không có gì - tôi có 2 loại UITableViewCell trong một UITableView. Dữ liệu in hoạt động trơn tru, nhưng không có cách nào tôi có thể quản lý để hiển thị kiểm soát sắp xếp lại: / – raistlin

4

Bạn nên sử dụng phương pháp này để ẩn nút xóa.

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { 
    return UITableViewCellEditingStyleNone; 
} 
Các vấn đề liên quan