1
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

Directory *aDirectory = [appDelegate.directories objectAtIndex:indexPath.row];
    _XMLDetailsView.aDirectory = aDirectory;

if (indexPath.section == 0) // First section
{
    _XMLDetailsView.aDirectory = aDirectory;
}
else if(indexPath.section == 1) // Second Section
{
    Directory *aDirectory = [appDelegate.directories objectAtIndex:indexPath.row +[listOfItems count]];
    _XMLDetailsView.aDirectory = aDirectory;

}
else if(indexPath.section == 2) // Third Section
{
    Directory *aDirectory = [appDelegate.directories objectAtIndex:indexPath.row +[listOfItems count] +3];
    _XMLDetailsView.aDirectory = aDirectory;

}
else if(indexPath.section == 3) // Fourth Section
{
    Directory *aDirectory = [appDelegate.directories objectAtIndex:indexPath.row +[listOfItems count] +9];
    _XMLDetailsView.aDirectory = aDirectory;

}

}

これは、特定のセクションから特定の値の行を選択する正しい方法ですか? たとえば、セクション "C" に対して didSelectRowAtIndexpath を実行すると、配列 (4) から始まる値が表示されると想定されるためです。ただし、代わりにセクション "C" に、array(0) からの値が再度表示されます。私はこれに長い間立ち往生しています。何か提案や助けがある人はいますか?

4

2 に答える 2

0
else if(indexPath.section == 2) // Third Section
{

    if(indexPath.row >4)
    {
        Directory *aDirectory = [appDelegate.directories objectAtIndex:indexPath.row +[listOfItems count] +3];
       _XMLDetailsView.aDirectory = aDirectory;
    }
}

これを試してみてください。役立つと思います。

于 2011-05-09T07:20:41.493 に答える
0
Directory *aDirectory = [appDelegate.directories objectAtIndex:indexPath.row];

メソッドの開始時のステートメントはindexPath.row、正しいセクションからではないディレクトリを使用して選択します。これを試してくださいindexPath.section

 Directory *aDirectory = [appDelegate.directories objectAtIndex:indexPath.section];
于 2011-05-09T07:04:49.863 に答える