2011-09-13 13 views
0

テーブルビューデリゲートでは、indexPathが送信されます。これをローカル変数に代入して調整することは可能ですか?私はクラス参照のドキュメントで何も見たことがありませんでした。indexPathを調整することは可能ですか?

私がしようとしているのは、indexPath.rowに1を加えたものです。

このコードは機能しませんが、ここでは基本的な考え方を理解しています。事前

+0

NSIndexPathは不変です。 http://stackoverflow.com/questions/1331659/nsindexpath-incrementing-values – cellcortex

答えて

3

にあなたが私はあなたがそれを「調整」によって何を意味するのか分かりませんが

NSIndexPath *tempIndex = [NSIndexPath indexPathForRow:indexPath.row + 1 inSection:indexPath.section]; 

を呼び出すことによって、別のNSIndexPathを取得することができます

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSIndexPath *tempIndex; 
    tempIndex = indexPath; 
    tempIndex.row = tempIndex.row + 1; 
//etc... 
} 

感謝。通常、cellForRowAtIndexPathでは、要求されたパス/セルで動作しません。

関連する問題