2009-09-01 13 views
18

Rozwijam grę, w której używam komórki UITableView, która ma niestandardową komórkę (podklasa UItableViewCell).zmiana kolejności w UITableView

W trybie edycji: Powinna pojawić się tylko zmieniona kontrola UITableView.

Właśnie dostaję usunięcie i zmianę kolejności.

Jak uzyskać tylko zmianę kolejności podczas edycji?

Odpowiedz

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

Aby dissmiss usuwać kontrolę, w UITableViewDelegate dodać

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

dzięki dużo oxigen to działało .... Pisałam to w

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

ale odczuwało napisz metodę, którą podałeś

Dziękuję tonom

61

Wiem, że ta odpowiedź może być spóźniona, ale przedstawiam ją tylko osobom, które jej potrzebują. Wystarczy wdrożyć następujące metody:

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

nadal nic - Mam 2 rodzaje UITableViewCell w jednym UITableView. Drukowanie danych działa sprawnie, ale w żaden sposób nie udaje mi się pokazać zmiany układu: / – raistlin

4

należy używać tej metody do ukrywania przycisk Usuń.

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { 
    return UITableViewCellEditingStyleNone; 
} 
Powiązane problemy