0

iPhoneの「設定」アプリの「Wi-Fi」と同じように、最初のセクションのスイッチで次のセクションを表示するかどうかを切り替えるテーブルビューがあります。

insertSections: withRowAnimation:を使用しdeleteSections: withRowAnimation:て更新した後、正常に動作しましたtableView: numberOfRowsInSection:。ただし、「設定」の「Wi-Fi」とは異なり、削除されたすべてのセクションはフェードアウトする前に一緒に折りたたまれます。

「Wi-Fi」と同じ効果を実現したいと思います。セクションがビューから削除されると、セクションが個別に折りたたまれます。

これを行うための推奨される方法は何ですか?

4

1 に答える 1

0

deleteSectionsセクションごとに呼び出すことができました:

static int nos = 4;

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return nos;
}

-(IBAction)onFadeTableButton:(id)sender
{
    NSMutableIndexSet *sectionsToDelete = [NSMutableIndexSet indexSet];
    [sectionsToDelete addIndex:3];

    nos = 3;
    [self.tableView deleteSections:sectionsToDelete
                  withRowAnimation:UITableViewRowAnimationTop];

    [sectionsToDelete addIndex:2];
    [sectionsToDelete removeIndex:3];
    nos = 2;
    [self.tableView deleteSections:sectionsToDelete
                  withRowAnimation:UITableViewRowAnimationMiddle];


    [sectionsToDelete addIndex:1];
    [sectionsToDelete removeIndex:2];
    nos = 1;
    [self.tableView deleteSections:sectionsToDelete
                  withRowAnimation:UITableViewRowAnimationMiddle];

    [sectionsToDelete addIndex:0];
    [sectionsToDelete removeIndex:1];
    nos = 0;
    [self.tableView deleteSections:sectionsToDelete
                  withRowAnimation:UITableViewRowAnimationMiddle];

}

コードは醜いので、既存のプロジェクト (4 つのセクションを含むテーブル ビュー) をすぐに使用していましたが、アイデアは明確でなければなりません。そのまま使わず、キレイにしてください。

于 2012-05-20T20:11:48.323 に答える