2012-05-09 3 views
0

誰かがこの状況に遭遇しましたか?行を並べ替えると、最後の行のソースインデックスパスが '0'に設定されています

セルを最下部から最上部まで順番に並べ替えると、クラッシュすることがあります。これらのクラッシュは、iSourceIndexPath.rowが0になったときに発生します。私はいつもピッキングしている最後の行であるため、iSourceIndexPath.rowが0になっているのだろうかと思います。どんな手掛かり?

- (NSIndexPath *)tableView:(UITableView *)iTableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)iSourceIndexPath toProposedIndexPath:(NSIndexPath *)iProposedDestinationIndexPath { 
    NSIndexPath *aReturnIndexPath = iProposedDestinationIndexPath; 
    if(iProposedDestinationIndexPath.row == 0) { 
     aReturnIndexPath = iSourceIndexPath; 
    } 

    NSLog(@"iProposedDestinationIndexPath=%d iSourceIndexPath=%d aReturnIndexPath=%d",iProposedDestinationIndexPath.row,iSourceIndexPath.row,aReturnIndexPath.row); 
    return aReturnIndexPath; 
} 
+0

クラッシュは何を言いますか?例外情報を表示する – aryaxt

+0

テーブルをリロードする必要がありますか? - (void)tableView:(UITableView *)iTableView moveRowAtIndexPath:(NSIndexPath *)iFromIndexPath toIndexPath:(NSIndexPath *)iToIndexPath? – Abhinav

答えて

0

セルを移動した後にテーブルをリロードするのを忘れました。その中の細胞の通常の取り扱いとは別に、これを行うべきです。

- (void)tableView:(UITableView *)iTableView moveRowAtIndexPath:(NSIndexPath *)iFromIndexPath toIndexPath:(NSIndexPath *)iToIndexPath { 
    [self.tableView reloadData] 
} 
関連する問題